stategate_client_go

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a stategate gRPC client

func NewClient

func NewClient(ctx context.Context, target string, opts ...Opt) (*Client, error)

NewClient creates a new stategate client - a pluggable API and "Application State Gateway" that enforces the [Event Sourcing Pattern](https://microservices.io/patterns/data/event-sourcing.html) for securely persisting & broadcasting application state changes

func (*Client) Close

func (c *Client) Close() error

Close closes the gRPC client connection

func (*Client) GetObject

func (c *Client) GetObject(ctx context.Context, in *stategate.ObjectRef) error

GetObject gets an object's current state values

func (*Client) SearchEvents

func (c *Client) SearchEvents(ctx context.Context, in *stategate.SearchEventOpts) (*stategate.Events, error)

SearchEvents returns an array of immutable historical events for a given object.

func (*Client) SearchObjects added in v0.2.2

func (c *Client) SearchObjects(ctx context.Context, in *stategate.SearchObjectOpts) (*stategate.Objects, error)

SearchObjects queries objects of a specific type

func (*Client) SetObject

func (c *Client) SetObject(ctx context.Context, in *stategate.Object) error

SetObject sets the current state value of an object, adds it to the event log, then broadcast the event to all interested consumers

func (*Client) StreamEvents

func (c *Client) StreamEvents(ctx context.Context, in *stategate.StreamOpts, fn func(even *stategate.Event) bool) error

StreamEvents creates an event stream/subscription to a given object type until fn returns false OR the context cancels. Event Consumers invoke this method.

type Opt

type Opt func(o *Options)

Opt is a single configuration option

func WithIDToken

func WithIDToken(idToken bool) Opt

WithIDToken makes the client use the oauth id token(if it exists) instead of the oauth access token

func WithLogging

func WithLogging(logging, logPayload bool) Opt

WithLogging registers a logging middleware

func WithMetrics

func WithMetrics(metrics bool) Opt

WithMetrics registers prometheus metrics

func WithTokenSource

func WithTokenSource(tokenSource oauth2.TokenSource) Opt

WithTokenSource uses oauth token add an authorization header to every outbound request

func WithTransportCreds

func WithTransportCreds(creds credentials.TransportCredentials) Opt

WithTransportCreds adds transport credentials to the client

type Options

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

Options holds configuration options

Jump to

Keyboard shortcuts

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