没有合适的资源?快使用搜索试试~ 我知道了~
首页使用Nancy构建.NET Core微服务:设计与实战指南
使用Nancy构建.NET Core微服务:设计与实战指南
需积分: 10 17 下载量 38 浏览量
更新于2024-07-18
收藏 4.81MB PDF 举报
"《微服务在.NET Core中的实践》是一本详尽的指南,专为开发人员讲解如何在.NET Core环境中构建微服务应用。微服务架构是一种将单个功能、独立且自治的服务通过API连接起来的方式,每个服务都是可独立部署的,并可能包含一个或多个进程,拥有自己的数据存储。这种架构强调清晰的接口定义、可靠的基础设施以及模块化的开发。 书中的主要内容包括: 1. 入门介绍:对微服务架构进行深入浅出的解释,帮助读者理解其核心理念和原则。 2. 实用技能:作者以OWIN(Open Web Interface for .NET)和Nancy框架为基础,教授如何利用这些工具进行实际的开发,减少不必要的代码量,简化微服务构建过程。 3. C#服务设计与实现:读者将学习如何用C#设计和构建具有单一功能的微服务,并了解如何组合它们构成一个功能完整的后台应用。 4. 生产与运维关注:书中还会涉及监控、日志记录和安全等关键的生产和运维问题,确保服务的稳定性和可靠性。 5. Nancy示例:书中包含丰富的实例,特别是使用Nancy框架创建HTTP API、事件通过Feeds暴露以及利用OWIN中间件进行基础架构管理。 通过阅读本书,开发人员不仅可以掌握微服务在.NET Core中的开发方法,还能了解到如何设计出既强大又易于运维的微服务,以及如何识别和构建符合微服务特性的小型服务组件。《微服务在.NET Core》是一本适合希望扩展技术栈并探索现代架构模式的.NET开发者的重要参考资料。"
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/10547908/bg10.jpg)
xiv
acknowledgments
Writing a book takes time—a lot of time. So the first thank you is to my wife, Jane
Horsdal Gammelgaard, for supporting me all the way through. You’re awesome, Jane.
I would like to thank my editor, Dan Maharry, who, through great suggestions, gen-
tle nudges, the occasional shove, and a relentless focus on creating a high-quality
product, pushed me to write a much better book than I would have otherwise. A big
thank you also goes to my technical editor, Michael Lund, for his thorough code
reviews and suggestions for improvements, and for ripping my line of reasoning apart
whenever it wasn’t clear. A special thanks to Karsten Strøbæk for his in-depth techni-
cal proofreading.
I can’t thank enough the amazing group of technical peer reviewers: Andy Kirsch,
Brian Rasmussen, Cemre Mengu, Guy Matthew LaCrosse, James McGinn, Jeff Smith,
Jim McGinn, Matt R. Cole, Morten Herman Langkjær, Nestor Narvaez, Nick McGin-
ness, Ronnie Hegelund, Samuel Bosch, and Shahid Iqbal. They suggested topics and
other ways of presenting topics and caught typos and mistakes in code and terminol-
ogy. Each pass through the review process and each piece of feedback provided
through the forum discussions helped shape the book.
Finally, I want to thank the people at Manning who made this book possible: pub-
lisher Marjan Bace, acquisitions editor Greg Wild, and everyone on the editorial and
production teams, including Tiffany Taylor, Katie Tennant, Melody Dolab, and Gor-
dan Salinovic.
![](https://csdnimg.cn/release/download_crawler_static/10547908/bg11.jpg)
xv
about this book
Microservices in .NET Core is a practical introduction to writing microservices in .NET
using lightweight and easy-to-use technologies, like the awesome Nancy web frame-
work and the powerful
OWIN (Open Web Interface for .NET) middleware. I’ve tried
to present the material in a way that will enable you to use what you learn right away.
To that end, I’ve tried to tell you why I build things the way I do, as well as show you
exactly how to build them.
The Nancy web framework, used throughout this book, was started by Andreas
Håkansson, who still leads the project. Andreas was soon joined by Steven Robbins,
and the two of them made Nancy great. Today Nancy is carried forward by Andreas,
Steven, the Nancy Minions (Kristian Hellang, Jonathan Channon, Damian Hickey,
Phillip Haydon, and myself), and the broader community. The full list of Nancy con-
tributors can be found at http://nancyfx.org/contribs.html.
OWIN is an open standard for the interface between web servers and web applica-
tions. The work on
OWIN was started in late 2010 by Ryan Riley, Benjamin van der
Veen, Mauricio Scheffer, and Scott Koon. Since then, a broad community has contrib-
uted to the
OWIN standard specification—through a Google group in the early days,
and now through the
OWIN GitHub repository (https://github.com/owin/owin)—
and to implementing
OWIN.
Who should read this book
Microservices in .NET Core is a developers’ book first, but architects and others can ben-
efit from it, too. I wrote it keeping in mind .
NET developers who want to get started
![](https://csdnimg.cn/release/download_crawler_static/10547908/bg12.jpg)
ABOUT THIS BOOK
xvi
writing distributed server-side systems in general and microservices in particular,
which means that the focus is on what a developer needs to know and do to write the
code for a system of microservices. Working knowledge of C# and a bit of
HTTP knowl-
edge is assumed.
How this book is organized
Microservices in .NET Core has 12 chapters spread across four parts:
Part 1 gives a quick introduction to microservices, answering what they are and why
they’re interesting. This part also introduces Nancy and
OWIN, the main technologies
used throughout the book.
■
Chapter 1 introduces microservices—what they are and why they matter. It
introduces the six characteristics of microservices that I use to guide the design
and implementation of microservices. At the end of the chapter, we say hello to
Nancy and
OWIN.
■
Chapter 2 is a comprehensive example of coding a microservice using Nancy
and
OWIN, along with the Polly library and .NET Core. At the end of the chap-
ter, we have a complete, albeit simple, microservice.
Part 2 covers how to split a system into microservices and how to implement function-
ality in a system of microservices.
■
Chapter 3 covers how to identify microservices and decide what to put into each
microservice. This chapter is about the design of a system of microservices as a
whole.
■
Chapter 4 shows how to design and implement the collaboration between
microservices. This chapter discusses the different ways microservices can col-
laborate and shows how to implement those collaborations.
■
Chapter 5 discusses where data should be stored in a system of microservices
and how some of the data may be replicated across several microservices.
■
Chapter 6 explains and demonstrates the implementation of some important
techniques for making microservice systems robust.
■
Chapter 7 takes a thorough look at testing a microservice system, including test-
ing the complete system, testing each microservice, and testing the code inside
the microservices.
Part 3 shows how to speed up development of new microservices by building a solid
microservice platform tailored to the needs of your particular system. Such a platform
provides implementations of a bunch of important concerns that cut across the entire
system of microservices, such as logging, monitoring, and security. In this part you’ll
build such a platform and see how it’s used to create new microservices quickly.
■
Chapter 8 gives an in-depth introduction to OWIN, walks through building
OWIN middleware, and shows how
OWIN middleware is well suited for han-
dling many crosscutting concerns.
![](https://csdnimg.cn/release/download_crawler_static/10547908/bg13.jpg)
ABOUT THIS BOOK
xvii
■
Chapter 9 explains the importance of monitoring and logging in a microservice
system. Building on the
OWIN knowledge from chapter 8, you’ll build OWIN
middleware implementing monitoring support and middleware that aids good
logging from your microservices.
■
Chapter 10 discusses security in a microservice system. The highly distributed
nature of a microservice system poses some security concerns that we discuss in
this chapter. I’ll also walk you through using
OWIN middleware to implement
security features in your microservices.
■
Chapter 11 builds on top of chapters 9 and 10 to create a microservice plat-
form. The platform is built by taking the
OWIN middleware from the previous
chapters and packaging it in NuGet packages ready to be shared across micros-
ervices. The chapter includes an example of creating a new microservice using
the platform.
Part 4 consists of chapter 12, which rounds off the book with some approaches to cre-
ating end-user applications for a microservices system. The chapter also shows how to
build a small application on top of some of the microservices from earlier chapters.
Together, the 12 chapters will teach you how to design and code microservices
using a lightweight, no-nonsense, .
NET-based technology stack.
Code conventions and downloads
Most chapters in this book have sample code. All of this can be found in the download
for this book on Manning’s site at https://www.manning.com/books/microservices-
in-net-core, or in the Git repository on GitHub found at https://github.com/hors-
dal/microservices-in-dotnetcore.
The code is based on .
NET Core, so to run it, you need to install .NET Core,
the dotnet command-line tool, and a suitable
IDE. You can find information on how
to set these up in appendix A.
Throughout the book, I use a number of third-party open source libraries, particu-
larly the Nancy web framework. .
NET Core is a big shift from “traditional” .NET, so
existing libraries need to be ported and thoroughly tested before they can claim full
.
NET Core support. At the time of writing .NET Core has just reached the 1.0.0 release,
so not all libraries have been tested on .
NET Core. For this reason, the book uses pre-
release versions of libraries—Nancy, for instance, is used in a pre-release version of
Nancy 2.0. If, when you read the book, there are stable releases for .
NET core of the
different libraries (for example, if the stable Nancy 2.0 is out), I recommend using
those as you code along with the examples.
In the GitHub repository, at https://github.com/horsdal/microservices-in-dotnet-
core, the master branch contains the code as it appears in the book. As stable releases
of libraries for .
NET Core come out, I plan to create a current branch and keep a copy
of the code there that I will keep mostly up-to-date with the latest versions of libraries
for a few years after publication of this book.
![](https://csdnimg.cn/release/download_crawler_static/10547908/bg14.jpg)
ABOUT THIS BOOK
xviii
This book contains many examples of source code, both in numbered listings and
inline with normal text. In both cases, source code is formatted in a
fixed-width
font
like
this
to separate it from ordinary text. Sometimes code is also in bold to high-
light code that has changed from previous steps in the chapter, such as when a new
feature adds to an existing line of code.
In many cases, the original source code has been reformatted; I’ve added line
breaks and reworked indentation to accommodate the available page space in the
book. In rare cases, even this was not enough, and listings include line-continuation
markers (
➥
). Additionally, comments in the source code have often been removed
from the listings when the code is described in the text. Code annotations accompany
many of the listings, highlighting important concepts.
Author Online
Purchase of Microservices in .NET Core includes free access to a private web forum run
by Manning Publications where you can make comments about the book, ask techni-
cal questions, and receive help from the author and from other users. To access the
forum and subscribe to it, point your web browser to https://www.manning.com/
books/microservices-in-net-core. This page provides information on how to get on
the forum once you are registered, what kind of help is available, and the rules of con-
duct on the forum. It also provides links to the source code for the examples in the
book, errata, and other downloads.
Manning’s commitment to our readers is to provide a venue where a meaningful
dialog between individual readers and between readers and the authors can take
place. It is not a commitment to any specific amount of participation on the part of
the authors, whose contribution to the forum remains voluntary (and unpaid). We
suggest you try asking the author challenging questions lest his interest strays!
The Author Online forum and the archives of previous discussions will be accessi-
ble from the publisher’s website as long as the book is in print.
About the author
Christian is an independent consultant with many years of experience building web
and distributed systems on .
NET as well as other platforms. He is part of the Nancy
maintainer team and is a Microsoft
MVP for .NET.
剩余347页未读,继续阅读
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/632de8c55def45ceb51e16aff3a4f0fb_zxfwinder.jpg!1)
zxfwinder
- 粉丝: 1
- 资源: 32
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 多模态联合稀疏表示在视频目标跟踪中的应用
- Kubernetes资源管控与Gardener开源软件实践解析
- MPI集群监控与负载平衡策略
- 自动化PHP安全漏洞检测:静态代码分析与数据流方法
- 青苔数据CEO程永:技术生态与阿里云开放创新
- 制造业转型: HyperX引领企业上云策略
- 赵维五分享:航空工业电子采购上云实战与运维策略
- 单片机控制的LED点阵显示屏设计及其实现
- 驻云科技李俊涛:AI驱动的云上服务新趋势与挑战
- 6LoWPAN物联网边界路由器:设计与实现
- 猩便利工程师仲小玉:Terraform云资源管理最佳实践与团队协作
- 类差分度改进的互信息特征选择提升文本分类性能
- VERITAS与阿里云合作的混合云转型与数据保护方案
- 云制造中的生产线仿真模型设计与虚拟化研究
- 汪洋在PostgresChina2018分享:高可用 PostgreSQL 工具与架构设计
- 2018 PostgresChina大会:阿里云时空引擎Ganos在PostgreSQL中的创新应用与多模型存储
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)