common

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package common implements shared functions and structs between various book* applications

Index

Constants

View Source
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"
)
View Source
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

func GetExpectedResponseCodeFromEnvVar(envVar, defaultValue string) int

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

func GetTracingHeaders(r *http.Request) map[string]string

GetTracingHeaders gets the tracing related header values from a request

func RestockBooks

func RestockBooks(amount int, headers map[string]string)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL