Documentation ¶
Overview ¶
Package common implements shared functions and structs between various book* applications
Index ¶
- Constants
- func GetBooks(participantName string, meshExpectedResponseCode int, booksCount *int64, ...)
- func GetExpectedResponseCodeFromEnvVar(envVar, defaultValue string) int
- func GetRawGenerator(books interface{}) func(http.ResponseWriter, *http.Request)
- func GetTracingHeaderKeys() []string
- func GetTracingHeaders(r *http.Request) map[string]string
- func RestockBooks(amount int, headers map[string]string)
- type BookBuyerPurchases
- type BookStorePurchases
- type BookThiefThievery
Constants ¶
const ( // Success is the string constant emitted at the end of the Bookbuyer/Bookthief logs when the test succeeded. Success = "MAESTRO! THIS TEST SUCCEEDED!" // Failure is the string constant emitted at the end of the Bookbuyer/Bookthief logs when the test failed. Failure = "MAESTRO, WE HAVE A PROBLEM! THIS TEST FAILED!" // BooksBoughtHeader is the header returned by the bookstore and observed by the bookbuyer. BooksBoughtHeader = "Booksbought" // IdentityHeader is the header returned by the bookstore and observed by the bookbuyer. IdentityHeader = "Identity" // BookstoreNamespaceEnvVar is the environment variable for the Bookbuyer namespace. BookstoreNamespaceEnvVar = "BOOKSTORE_NAMESPACE" // BookwarehouseNamespaceEnvVar is the environment variable for the Bookwarehouse namespace. BookwarehouseNamespaceEnvVar = "BOOKWAREHOUSE_NAMESPACE" // BookthiefExpectedResponseCodeEnvVar is the environment variable for Bookthief's expected HTTP response code BookthiefExpectedResponseCodeEnvVar = "BOOKTHIEF_EXPECTED_RESPONSE_CODE" // EnableEgressEnvVar is the environment variable to enable egress requests in the demo EnableEgressEnvVar = "ENABLE_EGRESS" )
const (
// RestockWarehouseURL is a header string constant.
RestockWarehouseURL = "restock-books"
)
Variables ¶
This section is empty.
Functions ¶
func GetBooks ¶
func GetBooks(participantName string, meshExpectedResponseCode int, booksCount *int64, booksCountV1 *int64, booksCountV2 *int64)
GetBooks reaches out to the bookstore and buys/steals books. This is invoked by the bookbuyer and the bookthief.
func GetExpectedResponseCodeFromEnvVar ¶
GetExpectedResponseCodeFromEnvVar returns the expected response code based on the given environment variable
func GetRawGenerator ¶
func GetRawGenerator(books interface{}) func(http.ResponseWriter, *http.Request)
GetRawGenerator returns a function that can be used to write a response of book data
func GetTracingHeaderKeys ¶
func GetTracingHeaderKeys() []string
GetTracingHeaderKeys returns header keys used for distributed tracing with Jaeger
func GetTracingHeaders ¶
GetTracingHeaders gets the tracing related header values from a request
func RestockBooks ¶
RestockBooks restocks the bookstore with certain amount of books from the warehouse.
Types ¶
type BookBuyerPurchases ¶
type BookBuyerPurchases struct { BooksBought int64 `json:"booksBought"` BooksBoughtV1 int64 `json:"booksBoughtV1"` BooksBoughtV2 int64 `json:"booksBoughtV2"` }
BookBuyerPurchases is all of the books that the bookbuyer has bought
type BookStorePurchases ¶
type BookStorePurchases struct {
BooksSold int64 `json:"booksSold"`
}
BookStorePurchases are all of the books sold from the bookstore
type BookThiefThievery ¶
type BookThiefThievery struct { BooksStolen int64 `json:"booksStolen"` BooksStolenV1 int64 `json:"booksStolenV1"` BooksStolenV2 int64 `json:"booksStolenV2"` }
BookThiefThievery is all of the books the bookthief has stolen