messagingapi

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package messagingapi implements the public API of the messaging.example microservice, including clients and data structures.

The Messaging microservice demonstrates service-to-service communication patterns.

Index

Constants

View Source
const Hostname = "messaging.example"

Hostname is the default hostname of the microservice: messaging.example.

Variables

View Source
var (
	URLOfHome         = httpx.JoinHostAndPath(Hostname, `:443/home`)
	URLOfNoQueue      = httpx.JoinHostAndPath(Hostname, `:443/no-queue`)
	URLOfDefaultQueue = httpx.JoinHostAndPath(Hostname, `:443/default-queue`)
	URLOfCacheLoad    = httpx.JoinHostAndPath(Hostname, `:443/cache-load`)
	URLOfCacheStore   = httpx.JoinHostAndPath(Hostname, `:443/cache-store`)
)

Fully-qualified URLs of the microservice's endpoints.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is an interface to calling the endpoints of the messaging.example microservice. This simple version is for unicast calls.

func NewClient

func NewClient(caller service.Publisher) *Client

NewClient creates a new unicast client to the messaging.example microservice.

func (*Client) CacheLoad

func (_c *Client) CacheLoad(r *http.Request) (res *http.Response, err error)

CacheLoad looks up an element in the distributed cache of the microservice.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) CacheLoad_Get

func (_c *Client) CacheLoad_Get(ctx context.Context, url string) (res *http.Response, err error)

CacheLoad_Get performs a GET request to the CacheLoad endpoint.

CacheLoad looks up an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) CacheLoad_Post

func (_c *Client) CacheLoad_Post(ctx context.Context, url string, contentType string, body any) (res *http.Response, err error)

CacheLoad_Post performs a POST request to the CacheLoad endpoint.

CacheLoad looks up an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*Client) CacheStore

func (_c *Client) CacheStore(r *http.Request) (res *http.Response, err error)

CacheStore stores an element in the distributed cache of the microservice.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) CacheStore_Get

func (_c *Client) CacheStore_Get(ctx context.Context, url string) (res *http.Response, err error)

CacheStore_Get performs a GET request to the CacheStore endpoint.

CacheStore stores an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) CacheStore_Post

func (_c *Client) CacheStore_Post(ctx context.Context, url string, contentType string, body any) (res *http.Response, err error)

CacheStore_Post performs a POST request to the CacheStore endpoint.

CacheStore stores an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*Client) DefaultQueue

func (_c *Client) DefaultQueue(r *http.Request) (res *http.Response, err error)

DefaultQueue demonstrates how the DefaultQueue subscription option is used to create a unicast request/response communication pattern. Only one of the instances of this microservice will respond to each request.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) DefaultQueue_Get

func (_c *Client) DefaultQueue_Get(ctx context.Context, url string) (res *http.Response, err error)

DefaultQueue_Get performs a GET request to the DefaultQueue endpoint.

DefaultQueue demonstrates how the DefaultQueue subscription option is used to create a unicast request/response communication pattern. Only one of the instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) DefaultQueue_Post

func (_c *Client) DefaultQueue_Post(ctx context.Context, url string, contentType string, body any) (res *http.Response, err error)

DefaultQueue_Post performs a POST request to the DefaultQueue endpoint.

DefaultQueue demonstrates how the DefaultQueue subscription option is used to create a unicast request/response communication pattern. Only one of the instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*Client) ForHost

func (_c *Client) ForHost(host string) *Client

ForHost replaces the default hostname of this client.

func (*Client) Home

func (_c *Client) Home(r *http.Request) (res *http.Response, err error)

Home demonstrates making requests using multicast and unicast request/response patterns.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) Home_Get

func (_c *Client) Home_Get(ctx context.Context, url string) (res *http.Response, err error)

Home_Get performs a GET request to the Home endpoint.

Home demonstrates making requests using multicast and unicast request/response patterns.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) Home_Post

func (_c *Client) Home_Post(ctx context.Context, url string, contentType string, body any) (res *http.Response, err error)

Home_Post performs a POST request to the Home endpoint.

Home demonstrates making requests using multicast and unicast request/response patterns.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*Client) NoQueue

func (_c *Client) NoQueue(r *http.Request) (res *http.Response, err error)

NoQueue demonstrates how the NoQueue subscription option is used to create a multicast request/response communication pattern. All instances of this microservice will respond to each request.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) NoQueue_Get

func (_c *Client) NoQueue_Get(ctx context.Context, url string) (res *http.Response, err error)

NoQueue_Get performs a GET request to the NoQueue endpoint.

NoQueue demonstrates how the NoQueue subscription option is used to create a multicast request/response communication pattern. All instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*Client) NoQueue_Post

func (_c *Client) NoQueue_Post(ctx context.Context, url string, contentType string, body any) (res *http.Response, err error)

NoQueue_Post performs a POST request to the NoQueue endpoint.

NoQueue demonstrates how the NoQueue subscription option is used to create a multicast request/response communication pattern. All instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*Client) WithOptions added in v1.13.1

func (_c *Client) WithOptions(opts ...pub.Option) *Client

WithOptions applies options to requests made by this client.

type MulticastClient

type MulticastClient struct {
	// contains filtered or unexported fields
}

MulticastClient is an interface to calling the endpoints of the messaging.example microservice. This advanced version is for multicast calls.

func NewMulticastClient

func NewMulticastClient(caller service.Publisher) *MulticastClient

NewMulticastClient creates a new multicast client to the messaging.example microservice.

func (*MulticastClient) CacheLoad

func (_c *MulticastClient) CacheLoad(ctx context.Context, r *http.Request) <-chan *pub.Response

CacheLoad looks up an element in the distributed cache of the microservice.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) CacheLoad_Get

func (_c *MulticastClient) CacheLoad_Get(ctx context.Context, url string) <-chan *pub.Response

CacheLoad_Get performs a GET request to the CacheLoad endpoint.

CacheLoad looks up an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) CacheLoad_Post

func (_c *MulticastClient) CacheLoad_Post(ctx context.Context, url string, contentType string, body any) <-chan *pub.Response

CacheLoad_Post performs a POST request to the CacheLoad endpoint.

CacheLoad looks up an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*MulticastClient) CacheStore

func (_c *MulticastClient) CacheStore(ctx context.Context, r *http.Request) <-chan *pub.Response

CacheStore stores an element in the distributed cache of the microservice.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) CacheStore_Get

func (_c *MulticastClient) CacheStore_Get(ctx context.Context, url string) <-chan *pub.Response

CacheStore_Get performs a GET request to the CacheStore endpoint.

CacheStore stores an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) CacheStore_Post

func (_c *MulticastClient) CacheStore_Post(ctx context.Context, url string, contentType string, body any) <-chan *pub.Response

CacheStore_Post performs a POST request to the CacheStore endpoint.

CacheStore stores an element in the distributed cache of the microservice.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*MulticastClient) DefaultQueue

func (_c *MulticastClient) DefaultQueue(ctx context.Context, r *http.Request) <-chan *pub.Response

DefaultQueue demonstrates how the DefaultQueue subscription option is used to create a unicast request/response communication pattern. Only one of the instances of this microservice will respond to each request.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) DefaultQueue_Get

func (_c *MulticastClient) DefaultQueue_Get(ctx context.Context, url string) <-chan *pub.Response

DefaultQueue_Get performs a GET request to the DefaultQueue endpoint.

DefaultQueue demonstrates how the DefaultQueue subscription option is used to create a unicast request/response communication pattern. Only one of the instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) DefaultQueue_Post

func (_c *MulticastClient) DefaultQueue_Post(ctx context.Context, url string, contentType string, body any) <-chan *pub.Response

DefaultQueue_Post performs a POST request to the DefaultQueue endpoint.

DefaultQueue demonstrates how the DefaultQueue subscription option is used to create a unicast request/response communication pattern. Only one of the instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*MulticastClient) ForHost

func (_c *MulticastClient) ForHost(host string) *MulticastClient

ForHost replaces the default hostname of this client.

func (*MulticastClient) Home

func (_c *MulticastClient) Home(ctx context.Context, r *http.Request) <-chan *pub.Response

Home demonstrates making requests using multicast and unicast request/response patterns.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) Home_Get

func (_c *MulticastClient) Home_Get(ctx context.Context, url string) <-chan *pub.Response

Home_Get performs a GET request to the Home endpoint.

Home demonstrates making requests using multicast and unicast request/response patterns.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) Home_Post

func (_c *MulticastClient) Home_Post(ctx context.Context, url string, contentType string, body any) <-chan *pub.Response

Home_Post performs a POST request to the Home endpoint.

Home demonstrates making requests using multicast and unicast request/response patterns.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*MulticastClient) NoQueue

func (_c *MulticastClient) NoQueue(ctx context.Context, r *http.Request) <-chan *pub.Response

NoQueue demonstrates how the NoQueue subscription option is used to create a multicast request/response communication pattern. All instances of this microservice will respond to each request.

If a request is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) NoQueue_Get

func (_c *MulticastClient) NoQueue_Get(ctx context.Context, url string) <-chan *pub.Response

NoQueue_Get performs a GET request to the NoQueue endpoint.

NoQueue demonstrates how the NoQueue subscription option is used to create a multicast request/response communication pattern. All instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint.

func (*MulticastClient) NoQueue_Post

func (_c *MulticastClient) NoQueue_Post(ctx context.Context, url string, contentType string, body any) <-chan *pub.Response

NoQueue_Post performs a POST request to the NoQueue endpoint.

NoQueue demonstrates how the NoQueue subscription option is used to create a multicast request/response communication pattern. All instances of this microservice will respond to each request.

If a URL is not provided, it defaults to the URL of the endpoint. Otherwise, it is resolved relative to the URL of the endpoint. If the body if of type io.Reader, []byte or string, it is serialized in binary form. If it is of type url.Values, it is serialized as form data. All other types are serialized as JSON. If a content type is not explicitly provided, an attempt will be made to derive it from the body.

func (*MulticastClient) WithOptions added in v1.13.1

func (_c *MulticastClient) WithOptions(opts ...pub.Option) *MulticastClient

WithOptions applies options to requests made by this client.

Jump to

Keyboard shortcuts

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