You are previewing Mastering ServiceStack.
O'Reilly logo
Mastering ServiceStack

Book Description

Utilize ServiceStack as the rock solid foundation of your distributed system

About This Book

  • Take advantage of the various data providers to access authentication and authorization, sessions, cache, and database

  • Leverage asynchronous processing for decoupling components to ease scaling

  • Monitor and tune the performance of your distributed system

  • Who This Book Is For

    Mastering ServiceStack is targeted at developers who have already implemented web services with ASMX, WCF, or ServiceStack and want to gain more insight into the possibilities ServiceStack has to offer to build distributed systems of all scales.

    What You Will Learn

  • Design a prudent and resilient API, following the RESTful design

  • Understand the internal processing chain and utilize the provided hooks

  • Incorporate ServiceStack as a full service provider to your existing distributed system

  • Leverage the power of asynchronous processing and add message queues to your architecture

  • Analyze and tune the performance of your service

  • In Detail

    Mastering ServiceStack covers real-life problems that occur over the lifetime of a distributed system and how to solve them by deeply understanding the tools of ServiceStack. Distributed systems is the enterprise solution that provide flexibility, reliability, scaling, and performance. ServiceStack is an outstanding tool belt to create such a system in a frictionless manner, especially sophisticated designed and fun to use.

    The book starts with an introduction covering the essentials, but assumes you are just refreshing, are a very fast learner, or are an expert in building web services. Then, the book explains ServiceStack's data transfer object patterns and teach you how it differs from other methods of building web services with different protocols, such as SOAP and SOA. It also introduces more low-level details such as how to extend the User Auth, message queues and concepts on how the technology works.

    By the end of this book, you will understand the concepts, framework, issues, and resolutions related to ServiceStack.

    Style and approach

    A step-by-step approach that follows the natural requirements of a distributed system in a conversational style.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Mastering ServiceStack
      1. Table of Contents
      2. Mastering ServiceStack
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Distributed Systems and How ServiceStack Jumps in
        1. A message-based service
        2. The processing chains of ServiceStack
          1. HTTP context
          2. Message Queue context
        3. A brief history of distributed systems
          1. The design principles of an API
            1. Usage convenience
            2. Documentation
            3. Consistency
            4. Robustness
            5. Authentication, authorization, and security
        4. Problems with distributed systems
          1. Complexity in design
            1. A broader set of skills
            2. Testing
            3. Rollout
            4. Operating overhead
            5. Tracing
            6. Contracts
          2. Issues at runtime
            1. (Un)atomicity of operations
            2. A shared register
            3. Performance
        5. Summary
      9. 2. ServiceStack as Your Unique Point of Access
        1. The IoC container
          1. Registering dependencies
          2. Resolving dependencies
          3. Lifetime of objects
          4. Disposal of objects
          5. Initialization of instances
          6. Custom IoC frameworks
          7. Incorporating the IoC container in your application
        2. The Ticket application
          1. Domain design
            1. The ticket model
            2. The comment model
          2. RESTful design
            1. The TicketService API
            2. The CommentService API
          3. Data access
          4. Functional contract testing
        3. Sessions
          1. Session sharing between your service and a web application
            1. Using the ServiceStack session
            2. Using the ASP.NET session
        4. Cache
          1. Caching session data
          2. Caching responses
        5. Authentication and authorization
          1. Authentication providers
          2. Authentication repository
          3. Limiting access
          4. Processing chain
          5. Adding authentication and authorization to the Ticket application
          6. Extending authentication and authorization
            1. Sliding authentication
            2. Extending the authentication session
            3. Customizing the user entity
            4. Authentication events
            5. Creating a custom authentication provider
            6. Provide credentials in RequestDTOs
            7. Authorization information in the HTTP header
        6. Summary
      10. 3. Asynchronous Communication between Components
        1. In Memory MQ
        2. RCON
        3. RedisMQ
          1. Setup
          2. Client managers
          3. Queues
          4. Replying directly back to the producer
          5. Integrate a RedisMQ client into your service
        4. RabbitMQ
          1. Setup
          2. Processing chain
          3. Replying directly back to the producer
          4. Broadcasting a message
          5. Integrate RabbitMQ into your service
        5. Server-sent events
          1. Sending messages from the server
          2. Hooks at the client-side
            1. Subscription events
            2. Receiving messages
            3. Sending messages
          3. Server-side usage of server-sent events
            1. Receiving messages
            2. Sending messages
          4. Configure ServerEventsFeature
          5. Redis server events
        6. Look left and right
          1. Authentication
          2. Filtering requests and responses
          3. Statistics
        7. Summary
      11. 4. Analyzing and Tuning a Distributed System
        1. Request logging
          1. Using another data store for your request log entries
          2. Centralizing request logging
          3. Tracking requests of your website
        2. Profiling requests
          1. Profiling self-hosted requests
          2. Profiling database requests
          3. Adding custom steps for fine-grained profiling
          4. Centralizing request profiling
        3. Minimizing the footprint of HTTP requests
          1. Batching requests
            1. Customizing automatic batching
            2. Implementing a RequestDTO to represent a collection
          2. Compressing requests
          3. Compressing responses
          4. Adding MessagePack format
          5. Adding Protobuf format
        4. Accessing information provided by RequestInfoFeature
        5. Summary
      12. 5. Documentation and Versioning
        1. Metadata page
          1. Extending the documentation of an operation
          2. Configuring the Metadata page
            1. Customizing templates
              1. HtmlFormat.html
              2. IndexOperations.html
              3. OperationControl.html
          3. Type generator
        2. Querying your service with Swagger
        3. Querying your service with Postman
        4. Versioning requests
        5. Validating your requests
          1. Querying the registered ValdationRules with an API
        6. Summary
      13. 6. Extending ServiceStack
        1. Writing your own plugin
        2. Intercepting requests and responses
        3. Registering new services and endpoints
        4. Summary
      14. Index