Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // HTTP takes care of the raw HTTP request/response logic used when communicating w/ remote services. HTTP *http.Client // BaseURL contains the protocol/host/port/etc that is the prefix for all service function // endpoints. (e.g. "http://api.myawesomeapp.com") BaseURL string // Name is just the display name of the service; used only for debugging/tracing purposes. Name string // contains filtered or unexported fields }
Client manages all RPC communication with other frodo-powered services. It uses HTTP under the hood, so you can supply a custom HTTP client by including WithHTTPClient() when calling your client constructor, NewXxxServiceClient().
func NewClient ¶
func NewClient(name string, addr string, options ...ClientOption) Client
NewClient constructs the RPC client that does the "heavy lifting" when communicating with remote frodo-powered RPC services. It contains all data/logic required to marshal/unmarshal requests/responses as well as communicate w/ the remote service.
func (Client) Invoke ¶
func (c Client) Invoke(ctx context.Context, method string, path string, serviceRequest any, serviceResponse any) error
Invoke handles the standard request/response logic used to call a service method on the remote service. You should NOT call this yourself. Instead, you should stick to the strongly typed, code-generated service functions on your client.
type ClientMiddlewareFunc ¶
type ClientMiddlewareFunc func(request *http.Request, next RoundTripperFunc) (*http.Response, error)
ClientMiddlewareFunc is a round-tripper-like function that accepts a request and returns a response/error combo, but also accepts 'next' (the rest of the computation) so that you can short circuit the execution as you see fit.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a single configurable setting that modifies some attribute of the RPC client when building one via NewClient().
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient allows you to provide an HTTP client configured to your liking. You do not *need* to supply this. The default client already implements a 30 second timeout, but if you want a different timeout or custom dialer/transport/etc, then you can feed in you custom client here and we'll use that one for all HTTP communication with other services.
func WithMiddleware ¶
func WithMiddleware(funcs ...ClientMiddlewareFunc) ClientOption
WithMiddleware sets the chain of HTTP request/response handlers you want to invoke on each service function invocation before/after we dispatch the HTTP request.
type RoundTripperFunc ¶
RoundTripperFunc matches the signature of the standard http.RoundTripper interface.