List of Listings

Chapter 3. Interprocess communication in a microservice architecture

Listing 3.1. An excerpt of the gRPC API for the Order Service

Chapter 4. Managing transactions with sagas

Listing 4.1. The OrderService class and its createOrder() method

Listing 4.2. The definition of the CreateOrderSaga

Listing 4.3. The definition of the third step of the saga

Listing 4.4. CreateOrderSagaState stores the state of a saga instance

Listing 4.5. KitchenServiceProxy defines the command message endpoints for Kitchen Service

Listing 4.6. The command handlers for Order Service

Listing 4.7. The OrderServiceConfiguration is a Spring @Configuration class that defines the Spring @Beans for the Order Service.

Chapter 5. Designing business logic in a microservice architecture

Listing 5.1. The OrderCreated event and the DomainEventEnvelope class

Listing 5.2. The enriched OrderCreated event

Listing 5.3. The Ticket aggregate’s accept() method

Listing 5.4. KitchenService calls Ticket.accept()

Listing 5.5. The Ticket extends a superclass, which records domain events

Listing 5.6. The Eventuate Tram framework’s DomainEventPublisher interface

Listing 5.7. The abstract superclass of type-safe domain event publishers

Listing 5.8. A type-safe interface for publishing Ticket aggregates’ domain events

Listing 5.9. Dispatching events to event handler methods

Listing 5.10. Part of the Ticket class, which is a JPA entity

Listing 5.11. Some of the Ticket’s methods

Listing 5.12. The service’s accept() method updates Ticket

Listing 5.13. Handling command messages sent by sagas

Listing 5.14. The Order class and its fields

Listing 5.15. The methods that are invoked during order creation

Listing 5.16. The Order method for revising an Order

Listing 5.17. The OrderService class has methods for creating and managing orders

Chapter 6. Developing business logic with event sourcing

Listing 6.1. The Order aggregate’s fields and its methods that initialize an instance

Listing 6.2. The process() and apply() methods that revise an Order aggregate

Listing 6.3. The Eventuate version of the Order class

Listing 6.4. OrderService uses an AggregateRepository

Listing 6.5. An event handler for OrderCreatedEvent

Listing 6.6. Handles command messages sent by sagas

Chapter 7. Implementing queries in a microservice architecture

Listing 7.1. Event handlers that call the OrderHistoryDao

Listing 7.2. The addOrder() method adds or updates an Order

Listing 7.3. The notePickedUp() method changes the order status to PICKED_UP

Listing 7.4. The idempotentUpdate() method ignores duplicate events

Listing 7.5. The findOrderHistory() method retrieves a consumer’s matching orders

Chapter 8. External API patterns

Listing 8.1. Fetching the order details by calling the backend services sequentially

Listing 8.2. The Spring @Beans that implement the /orders endpoints

Listing 8.3. The externalized configuration of backend service URLs

Listing 8.4. The OrderHandlers class implements custom request-handling logic.

Listing 8.5. OrderService class—a remote proxy for Order Service

Listing 8.6. The main() method for the API gateway

Listing 8.7. The GraphQL schema for the FTGO API gateway

Listing 8.8. Attaching the resolver functions to fields of the GraphQL schema

Listing 8.9. Using a DataLoader to optimize calls to Restaurant Service

Listing 8.10. Integrating the GraphQL server with the Express web framework

Listing 8.11. Using the Apollo GraphQL client to execute queries

Chapter 9. Testing microservices: Part 1

Listing 9.1. A contract that describes how API Gateway invokes Order Service

Listing 9.2. A simple, fast-running unit test for the Order entity

Listing 9.3. A simple, fast-running test for the Money value object

Listing 9.4. A simple, fast-running unit test for CreateOrderSaga

Listing 9.5. A simple, fast-running unit test for the OrderService class

Listing 9.6. A simple, fast-running unit test for the OrderController class

Listing 9.7. A fast-running unit test for the OrderEventConsumer class

Chapter 10. Testing microservices: Part 2

Listing 10.1. An integration test that verifies that an Order can be persisted

Listing 10.2. A contract that describes an HTTP-based request/response style interaction

Listing 10.3. The abstract base class for the tests code-generated by Spring Cloud Contract

Listing 10.4. A consumer-side integration test for API Gateway’s OrderServiceProxy

Listing 10.5. A contract for a publish/subscribe interaction style

Listing 10.6. The abstract base class for the Spring Cloud Contract provider-side tests

Listing 10.7. The consumer-side integration test for the OrderHistoryEventHandlers class

Listing 10.8. Contract describing how Order Service asynchronously invokes Kitchen Service

Listing 10.9. The consumer-side contract integration test for Order Service

Listing 10.10. Superclass of provider-side, consumer-driven contract tests for Kitchen Service

Listing 10.11. The Gherkin definition of the Place Order feature and some of its scenarios

Listing 10.12. The Java step definitions class makes the Gherkin scenarios executable.

Listing 10.13. The @GivenuseCreditCard() method defines the meaning of the Given using ... credit card step.

Listing 10.14. The placeOrder() method defines the When I place an order for Chicken Vindaloo at Ajanta step.

Listing 10.15. The @ThentheOrderShouldBe() method verifies HTTP request was successful.

Listing 10.16. The Cucumber step definitions class for the Order Service component tests

Listing 10.17. A Gherkin-based specification of a user journey

Chapter 11. Developing production-ready services

Listing 11.1. OrderService tracks the number of orders placed, approved, and rejected.

Chapter 12. Deploying microservices

Listing 12.1. The Dockerfile used to build Restaurant Service

Listing 12.2. The shell commands used to build the container image for Restaurant Service

Listing 12.3. Using docker run to run a containerized service

Listing 12.4. Kubernetes Deployment for ftgo-restaurant-service

Listing 12.5. The YAML definition of the Kubernetes service for ftgo-restaurant-service

Listing 12.6. The YAML definition of a NodePort service that routes traffic to port 8082 of Consumer Service

Listing 12.7. Deploying Consumer Service with Istio

Listing 12.8. A Java lambda function is a class that implements the RequestHandler interface.

Listing 12.9. The handler class for GET /restaurant/{restaurantId}

Listing 12.10. An abstract RequestHandler that implements dependency injection

Listing 12.11. An abstract RequestHandler that catches exceptions and returns a 500 HTTP response

Listing 12.12. The serverless.yml deploys Restaurant Service.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset