ENGLISH

Microservices in .NET Core, with Examples in Nancy

Book information

Year
2017
ISBN
1617293377
Language
english
Format
PDF
Filesize
6 MB (6098651 bytes)
Pages
348\348
Time added
2018-12-26 10:03:35

Description

Microservices in .NET Core......Page 1 brief contents......Page 7 contents......Page 9 preface......Page 15 acknowledgments......Page 16 Who should read this book......Page 17 How this book is organized......Page 18 Code conventions and downloads......Page 19 About the author......Page 20 about the cover illustration......Page 21 Part 1: Getting started with microservices......Page 23 1.1 What is a microservice?......Page 25 1.1.2 Microservice characteristics......Page 27 1.2 Why microservices?......Page 32 1.2.1 Enabling continuous delivery......Page 33 1.2.2 High level of maintainability......Page 34 1.3 Costs and downsides of microservices......Page 35 1.4 Greenfield vs. brownfield......Page 36 1.5 Code reuse......Page 37 1.6 Serving a user request: an example of how microservices work in concert......Page 38 1.6.1 Main handling of the user request......Page 39 1.6.2 Side effects of the user request......Page 40 1.6.3 The complete picture......Page 41 1.7.1 Nancy......Page 42 1.7.2 OWIN......Page 43 1.7.3 Setting up a development environment......Page 44 1.8 A simple microservices example......Page 45 1.8.2 Adding Nancy to the project......Page 46 1.8.3 Adding a Nancy module with an implementation of the endpoint......Page 47 1.8.4 Adding OWIN middleware......Page 49 1.9 Summary......Page 50 Chapter 2: A basic shopping cart microservice......Page 52 2.1 Overview of the Shopping Cart microservice......Page 53 2.1.1 Components of the Shopping Cart microservice......Page 55 2.2.1 Creating an empty project......Page 56 2.2.2 The Shopping Cart microservice’s API for other services......Page 57 2.2.3 Fetching product information......Page 64 2.2.4 Parsing the product response......Page 66 2.2.5 Adding a failure-handling policy......Page 68 2.2.6 Implementing a basic event feed......Page 70 2.4 Summary......Page 74 Part 2: Building microservices......Page 77 Chapter 3: Identifying and scoping microservices......Page 79 3.1.1 What is a business capability?......Page 80 3.1.2 Identifying business capabilities......Page 81 3.1.3 Example: point-of-sale system......Page 82 3.2.2 Examples of supporting technical capabilities......Page 87 3.3 What to do when the correct scope isn’t clear......Page 91 3.3.1 Starting a bit bigger......Page 92 3.3.2 Carving out new microservices from existing microservices......Page 95 3.4 Well-scoped microservices adhere to the microservice characteristics......Page 97 3.4.2 Secondarily scoping to supporting technical capabilities leads to good microservices......Page 98 3.5 Summary......Page 99 Chapter 4: Microservice collaboration......Page 101 4.1 Types of collaboration: commands, queries, and events......Page 102 4.1.1 Commands and queries: synchronous collaboration......Page 104 4.1.2 Events: asynchronous collaboration......Page 107 4.1.3 Data formats......Page 109 4.2 Implementing collaboration......Page 110 4.2.1 Setting up a project for Loyalty Program......Page 111 4.2.3 Implementing commands with HTTP POST or PUT......Page 113 4.2.4 Implementing queries with HTTP GET......Page 117 4.2.5 Data formats......Page 118 4.2.6 Implementing an event-based collaboration......Page 120 4.3 Summary......Page 129 Chapter 5: Data ownership and data storage......Page 131 5.2.1 Rule 1: Ownership of data follows business capabilities......Page 132 5.2.2 Rule 2: Replicate for speed and robustness......Page 135 5.2.3 Where does a microservice store its data?......Page 138 5.3 Implementing data storage in a microservice......Page 140 5.3.1 Storing data owned by a microservice......Page 141 5.3.2 Storing events raised by a microservice......Page 144 5.3.3 Setting cache headers in Nancy responses......Page 151 5.3.4 Reading and using cache headers......Page 152 5.4 Summary......Page 154 Chapter 6: Designing for robustness......Page 156 6.1 Expect failures......Page 157 6.1.1 Keeping good logs......Page 158 6.1.3 Rolling forward vs. rolling back......Page 160 6.1.4 Don’t propagate failures......Page 161 6.2 The client side’s responsibility for robustness......Page 162 6.2.1 Robustness pattern: retry......Page 164 6.2.2 Robustness pattern: circuit breaker......Page 166 6.3 Implementing robustness patterns......Page 168 6.3.1 Implementing a fast-paced retry strategy with Polly......Page 170 6.3.2 Implementing a circuit breaker with Polly......Page 171 6.3.3 Implementing a slow-paced retry strategy......Page 172 6.3.4 Logging all unhandled exceptions......Page 175 6.4 Summary......Page 176 Chapter 7: Writing tests for microservices......Page 177 7.1.1 The test pyramid: what to test in a microservices system......Page 178 7.1.2 System-level tests: testing a complete microservice system end-to-end......Page 179 7.1.3 Service-level tests: testing a microservice from outside its process......Page 180 7.1.4 Unit-level tests: testing endpoints from within the process......Page 183 7.2.1 Meet Nancy.Testing......Page 184 7.2.3 xUnit and Nancy.Testing working together......Page 185 7.3 Writing unit tests using Nancy.Testing......Page 186 7.3.1 Setting up a unit-test project......Page 187 7.3.2 Using the Browser object to unit-test endpoints......Page 189 7.3.3 Using a configurable bootstrapper to inject mocks into endpoints......Page 192 7.4 Writing service-level tests......Page 195 7.4.2 Creating mocked endpoints......Page 197 7.4.3 Starting all the processes of the microservice under test......Page 199 7.4.4 Executing the test scenario against the microservice under test......Page 201 7.5 Summary......Page 202 Part 3: Handling cross-cutting concerns: building a reusable microservice platform......Page 205 Chapter 8: Introducing OWIN: writing and testing OWIN middleware......Page 207 8.1 Handling cross-cutting concerns......Page 208 8.2 The OWIN pipeline......Page 210 8.2.1 What belongs in OWIN, and what belongs in Nancy?......Page 213 8.3 Writing middleware......Page 214 8.3.1 Middleware as lambdas......Page 215 8.3.2 Middleware classes......Page 216 8.4 Testing middleware and pipelines......Page 217 8.5 Summary......Page 220 Chapter 9: Cross-cutting concerns: monitoring and logging......Page 221 9.1 Monitoring needs in microservices......Page 222 9.2 Logging needs in microservices......Page 225 9.2.1 Structured logging with Serilog......Page 227 9.3 Implementing the monitoring middleware......Page 228 9.3.1 Implementing the shallow monitoring endpoint......Page 229 9.3.2 Implementing the deep monitoring endpoint......Page 230 9.3.3 Adding the monitoring middleware to the OWIN pipeline......Page 232 9.4 Implementing the logging middleware......Page 234 9.4.1 Adding correlation tokens to all log messages......Page 236 9.4.2 Adding a correlation token to all outgoing HTTP requests......Page 237 9.4.3 Logging requests and request performance......Page 241 9.4.4 Configuring an OWIN pipeline with a correlation token and logging middleware......Page 242 9.5 Summary......Page 244 Chapter 10: Securing microservice-to- microservice communication......Page 245 10.1 Microservice security concerns......Page 246 10.1.1 Authenticating users at the edge......Page 247 10.1.2 Authorizing users in microservices......Page 248 10.1.3 How much should microservices trust each other?......Page 249 10.2 Implementing secure microservice-to-microservice communication......Page 251 10.2.1 Meet IdentityServer......Page 253 10.2.2 Implementing authentication with IdentityServer middleware......Page 259 10.2.3 Implementing microservice-to-microservice authorization with IdentityServer and middleware......Page 261 10.2.4 Implementing user authorization in Nancy modules......Page 264 10.3 Summary......Page 268 Chapter 11: Building a reusable microservice platform......Page 270 11.2 Creating a reusable microservice platform......Page 271 11.3 Packaging and sharing middleware with NuGet......Page 273 11.3.1 Creating a package with logging and monitoring middleware......Page 274 11.3.2 Creating a package with authorization middleware......Page 281 11.3.3 Creating a package with rest client factory......Page 284 11.3.4 Automatically registering an HTTP client factory in Nancy’s container......Page 287 11.3.5 Using the microservice platform......Page 289 11.4 Summary......Page 292 Part 4: Building applications......Page 293 Chapter 12: Creating applications over microservices......Page 295 12.1.1 General-purpose applications......Page 296 12.1.2 Specialized applications......Page 297 12.2.1 Composite applications: integrating at the frontend......Page 298 12.2.2 API gateway......Page 301 12.2.3 Backend for frontend (BFF) pattern......Page 303 12.2.4 When to use each pattern......Page 304 12.2.5 Client-side or server-side rendering?......Page 305 12.3 Example: a shopping cart and product list......Page 306 12.3.1 Creating an API gateway......Page 309 12.3.2 Creating the product list GUI......Page 311 12.3.3 Creating the shopping cart GUI......Page 316 12.3.4 Letting users add products to the shopping cart......Page 319 12.3.5 Letting users remove products from the shopping cart......Page 321 12.4 Summary......Page 322 Appendix A: Development environment setup......Page 325 A.1.3 ATOM......Page 326 A.3 Setting up Yeoman ASP.NET generator......Page 327 A.4 Setting up Postman......Page 328 A.5 Installing SQL Server Express......Page 329 B.1 Deploying HTTP APIs......Page 330 B.1.3 Azure Web Apps......Page 331 B.2.2 Linux servers......Page 332 B.2.5 Amazon Lambda......Page 333 Software design and architecture in general......Page 334 Technologies used......Page 335 B......Page 337 D......Page 338 H......Page 339 M......Page 340 N......Page 341 R......Page 342 S......Page 343 Y......Page 344

Similar books

Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36

Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36

2010 · PDF

THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.

THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.

1858 · PDF

Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.

Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.

2022 · PDF