stategate

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package stategate is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_schema_proto protoreflect.FileDescriptor

Functions

func RegisterEventServiceHandler added in v0.4.0

func RegisterEventServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterEventServiceHandler registers the http handlers for service EventService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterEventServiceHandlerClient added in v0.4.0

func RegisterEventServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EventServiceClient) error

RegisterEventServiceHandlerClient registers the http handlers for service EventService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EventServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EventServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "EventServiceClient" to call the correct interceptors.

func RegisterEventServiceHandlerFromEndpoint added in v0.4.0

func RegisterEventServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterEventServiceHandlerFromEndpoint is same as RegisterEventServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterEventServiceHandlerServer added in v0.4.0

func RegisterEventServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EventServiceServer) error

RegisterEventServiceHandlerServer registers the http handlers for service EventService to "mux". UnaryRPC :call EventServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterEventServiceHandlerFromEndpoint instead.

func RegisterEventServiceServer added in v0.4.0

func RegisterEventServiceServer(s *grpc.Server, srv EventServiceServer)

func RegisterStateServiceHandler added in v0.5.0

func RegisterStateServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterStateServiceHandler registers the http handlers for service StateService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterStateServiceHandlerClient added in v0.5.0

func RegisterStateServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client StateServiceClient) error

RegisterStateServiceHandlerClient registers the http handlers for service StateService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "StateServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "StateServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "StateServiceClient" to call the correct interceptors.

func RegisterStateServiceHandlerFromEndpoint added in v0.5.0

func RegisterStateServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterStateServiceHandlerFromEndpoint is same as RegisterStateServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterStateServiceHandlerServer added in v0.5.0

func RegisterStateServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server StateServiceServer) error

RegisterStateServiceHandlerServer registers the http handlers for service StateService to "mux". UnaryRPC :call StateServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterStateServiceHandlerFromEndpoint instead.

func RegisterStateServiceServer added in v0.5.0

func RegisterStateServiceServer(s *grpc.Server, srv StateServiceServer)

Types

type Event

type Event struct {

	// Identifies the event(uuid).
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// state after it has been mutated
	State *State `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"`
	// The authentication claims of the event producer.
	Claims *_struct.Struct `protobuf:"bytes,3,opt,name=claims,proto3" json:"claims,omitempty"`
	// Timestamp(ns) of when the event was received.
	Time int64 `protobuf:"varint,4,opt,name=time,proto3" json:"time,omitempty"`
	// contains filtered or unexported fields
}

Event is primitive that represents a single state change Events are persisted to history & broadcasted to interested consumers(Stream) any time an application state value is created/modified Events are immutable after creation and may be searched. Event Consumers may search events to query previous state

func (*Event) Descriptor deprecated

func (*Event) Descriptor() ([]byte, []int)

Deprecated: Use Event.ProtoReflect.Descriptor instead.

func (*Event) GetClaims

func (x *Event) GetClaims() *_struct.Struct

func (*Event) GetId

func (x *Event) GetId() string

func (*Event) GetState added in v0.5.0

func (x *Event) GetState() *State

func (*Event) GetTime

func (x *Event) GetTime() int64

func (*Event) ProtoMessage

func (*Event) ProtoMessage()

func (*Event) ProtoReflect

func (x *Event) ProtoReflect() protoreflect.Message

func (*Event) Reset

func (x *Event) Reset()

func (*Event) String

func (x *Event) String() string

func (*Event) Validate

func (this *Event) Validate() error

type EventServiceClient added in v0.4.0

type EventServiceClient interface {
	// Stream creates an event stream/subscription to a given application state value type until fn returns false OR the context cancels.
	Stream(ctx context.Context, in *StreamOpts, opts ...grpc.CallOption) (EventService_StreamClient, error)
	// Search queries events related to a specific application state value.
	Search(ctx context.Context, in *SearchEventOpts, opts ...grpc.CallOption) (*Events, error)
}

EventServiceClient is the client API for EventService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewEventServiceClient added in v0.4.0

func NewEventServiceClient(cc grpc.ClientConnInterface) EventServiceClient

type EventServiceServer added in v0.4.0

type EventServiceServer interface {
	// Stream creates an event stream/subscription to a given application state value type until fn returns false OR the context cancels.
	Stream(*StreamOpts, EventService_StreamServer) error
	// Search queries events related to a specific application state value.
	Search(context.Context, *SearchEventOpts) (*Events, error)
}

EventServiceServer is the server API for EventService service.

type EventService_StreamClient added in v0.4.0

type EventService_StreamClient interface {
	Recv() (*Event, error)
	grpc.ClientStream
}

type EventService_StreamServer added in v0.4.0

type EventService_StreamServer interface {
	Send(*Event) error
	grpc.ServerStream
}

type Events

type Events struct {
	Events []*Event `protobuf:"bytes,1,rep,name=events,proto3" json:"events,omitempty"`
	// contains filtered or unexported fields
}

Events is an array of events

func (*Events) Descriptor deprecated

func (*Events) Descriptor() ([]byte, []int)

Deprecated: Use Events.ProtoReflect.Descriptor instead.

func (*Events) GetEvents

func (x *Events) GetEvents() []*Event

func (*Events) ProtoMessage

func (*Events) ProtoMessage()

func (*Events) ProtoReflect

func (x *Events) ProtoReflect() protoreflect.Message

func (*Events) Reset

func (x *Events) Reset()

func (*Events) String

func (x *Events) String() string

func (*Events) Validate

func (this *Events) Validate() error

type SearchEventOpts added in v0.2.2

type SearchEventOpts struct {

	// the application state value's business domain(ex: accounting)
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	// State type (ex: user)
	Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// filter events belonging to a particular application state value
	Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
	// json string to filter records that have application state value's with values that match k/v pairs ex: { "message": "hello world" }
	QueryString string `protobuf:"bytes,4,opt,name=query_string,json=queryString,proto3" json:"query_string,omitempty"`
	// only return application state value events that occurred after specified min timestamp
	Min int64 `protobuf:"varint,5,opt,name=min,proto3" json:"min,omitempty"`
	// only return application state value events that occurred before specified max timestamp
	Max int64 `protobuf:"varint,6,opt,name=max,proto3" json:"max,omitempty"`
	// limit returned application state value events
	Limit int64 `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"`
	// offset returned application state value events(pagination)
	Offset int64 `protobuf:"varint,8,opt,name=offset,proto3" json:"offset,omitempty"`
	// contains filtered or unexported fields
}

SearchEventOpts are options when querying historical events for a given application state value

func (*SearchEventOpts) Descriptor deprecated added in v0.2.2

func (*SearchEventOpts) Descriptor() ([]byte, []int)

Deprecated: Use SearchEventOpts.ProtoReflect.Descriptor instead.

func (*SearchEventOpts) GetDomain added in v0.4.0

func (x *SearchEventOpts) GetDomain() string

func (*SearchEventOpts) GetKey added in v0.2.2

func (x *SearchEventOpts) GetKey() string

func (*SearchEventOpts) GetLimit added in v0.2.2

func (x *SearchEventOpts) GetLimit() int64

func (*SearchEventOpts) GetMax added in v0.2.2

func (x *SearchEventOpts) GetMax() int64

func (*SearchEventOpts) GetMin added in v0.2.2

func (x *SearchEventOpts) GetMin() int64

func (*SearchEventOpts) GetOffset added in v0.2.2

func (x *SearchEventOpts) GetOffset() int64

func (*SearchEventOpts) GetQueryString added in v0.4.0

func (x *SearchEventOpts) GetQueryString() string

func (*SearchEventOpts) GetType added in v0.2.2

func (x *SearchEventOpts) GetType() string

func (*SearchEventOpts) ProtoMessage added in v0.2.2

func (*SearchEventOpts) ProtoMessage()

func (*SearchEventOpts) ProtoReflect added in v0.2.2

func (x *SearchEventOpts) ProtoReflect() protoreflect.Message

func (*SearchEventOpts) Reset added in v0.2.2

func (x *SearchEventOpts) Reset()

func (*SearchEventOpts) String added in v0.2.2

func (x *SearchEventOpts) String() string

func (*SearchEventOpts) Validate added in v0.2.2

func (this *SearchEventOpts) Validate() error

type SearchStateOpts added in v0.5.0

type SearchStateOpts struct {

	// the application state value's business domain(ex: accounting)
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	// State type (ex: user)
	Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// json string to filter records that have values match k/v pairs ex: { "message": "hello world" }
	QueryString string `protobuf:"bytes,3,opt,name=query_string,json=queryString,proto3" json:"query_string,omitempty"`
	// limit returned state
	Limit int64 `protobuf:"varint,4,opt,name=limit,proto3" json:"limit,omitempty"`
	// offset returned events(pagination)
	Offset int64 `protobuf:"varint,5,opt,name=offset,proto3" json:"offset,omitempty"`
	// contains filtered or unexported fields
}

SearchStateOpts are options when querying the current values of application state value(s). If historical values are needed, SearchEvents should be used

func (*SearchStateOpts) Descriptor deprecated added in v0.5.0

func (*SearchStateOpts) Descriptor() ([]byte, []int)

Deprecated: Use SearchStateOpts.ProtoReflect.Descriptor instead.

func (*SearchStateOpts) GetDomain added in v0.5.0

func (x *SearchStateOpts) GetDomain() string

func (*SearchStateOpts) GetLimit added in v0.5.0

func (x *SearchStateOpts) GetLimit() int64

func (*SearchStateOpts) GetOffset added in v0.5.0

func (x *SearchStateOpts) GetOffset() int64

func (*SearchStateOpts) GetQueryString added in v0.5.0

func (x *SearchStateOpts) GetQueryString() string

func (*SearchStateOpts) GetType added in v0.5.0

func (x *SearchStateOpts) GetType() string

func (*SearchStateOpts) ProtoMessage added in v0.5.0

func (*SearchStateOpts) ProtoMessage()

func (*SearchStateOpts) ProtoReflect added in v0.5.0

func (x *SearchStateOpts) ProtoReflect() protoreflect.Message

func (*SearchStateOpts) Reset added in v0.5.0

func (x *SearchStateOpts) Reset()

func (*SearchStateOpts) String added in v0.5.0

func (x *SearchStateOpts) String() string

func (*SearchStateOpts) Validate added in v0.5.0

func (this *SearchStateOpts) Validate() error

type State added in v0.5.0

type State struct {

	// the application state value's business domain(ex: accounting)
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	// State type (ex: user)
	Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// State key (unique within type)
	Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
	// State values (k/v pairs)
	Values *_struct.Struct `protobuf:"bytes,4,opt,name=values,proto3" json:"values,omitempty"`
	// contains filtered or unexported fields
}

State represents a single record(k/v pairs) with a unique key with a given [type](https://en.wikipedia.org/wiki/Type_system), belonging to a particular [domain](https://en.wikipedia.org/wiki/Domain-driven_design) Services/Users should use state related methods to persist & interact with the current state of an application/domain.

func (*State) Descriptor deprecated added in v0.5.0

func (*State) Descriptor() ([]byte, []int)

Deprecated: Use State.ProtoReflect.Descriptor instead.

func (*State) GetDomain added in v0.5.0

func (x *State) GetDomain() string

func (*State) GetKey added in v0.5.0

func (x *State) GetKey() string

func (*State) GetType added in v0.5.0

func (x *State) GetType() string

func (*State) GetValues added in v0.5.0

func (x *State) GetValues() *_struct.Struct

func (*State) ProtoMessage added in v0.5.0

func (*State) ProtoMessage()

func (*State) ProtoReflect added in v0.5.0

func (x *State) ProtoReflect() protoreflect.Message

func (*State) Reset added in v0.5.0

func (x *State) Reset()

func (*State) String added in v0.5.0

func (x *State) String() string

func (*State) Validate added in v0.5.0

func (this *State) Validate() error

type StateRef added in v0.5.0

type StateRef struct {

	// the application state value's business domain(ex: accounting)
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	// State type (ex: user)
	Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// State key (unique within type)
	Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"`
	// contains filtered or unexported fields
}

StateRef is a reference to an existing application state value

func (*StateRef) Descriptor deprecated added in v0.5.0

func (*StateRef) Descriptor() ([]byte, []int)

Deprecated: Use StateRef.ProtoReflect.Descriptor instead.

func (*StateRef) GetDomain added in v0.5.0

func (x *StateRef) GetDomain() string

func (*StateRef) GetKey added in v0.5.0

func (x *StateRef) GetKey() string

func (*StateRef) GetType added in v0.5.0

func (x *StateRef) GetType() string

func (*StateRef) ProtoMessage added in v0.5.0

func (*StateRef) ProtoMessage()

func (*StateRef) ProtoReflect added in v0.5.0

func (x *StateRef) ProtoReflect() protoreflect.Message

func (*StateRef) Reset added in v0.5.0

func (x *StateRef) Reset()

func (*StateRef) String added in v0.5.0

func (x *StateRef) String() string

func (*StateRef) Validate added in v0.5.0

func (this *StateRef) Validate() error

type StateServiceClient added in v0.5.0

type StateServiceClient interface {
	// Set sets the current state value of an application state value, adds it to the event log, then broadcast the event to all interested consumers
	Set(ctx context.Context, in *State, opts ...grpc.CallOption) (*empty.Empty, error)
	// Get gets an application state value's current state values
	Get(ctx context.Context, in *StateRef, opts ...grpc.CallOption) (*State, error)
	// Del hard deletes current state. State may be recovered via the Event store.
	Del(ctx context.Context, in *StateRef, opts ...grpc.CallOption) (*empty.Empty, error)
	// Search queries state belonging to a particular domain & of a specific type
	Search(ctx context.Context, in *SearchStateOpts, opts ...grpc.CallOption) (*StateValues, error)
}

StateServiceClient is the client API for StateService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewStateServiceClient added in v0.5.0

func NewStateServiceClient(cc grpc.ClientConnInterface) StateServiceClient

type StateServiceServer added in v0.5.0

type StateServiceServer interface {
	// Set sets the current state value of an application state value, adds it to the event log, then broadcast the event to all interested consumers
	Set(context.Context, *State) (*empty.Empty, error)
	// Get gets an application state value's current state values
	Get(context.Context, *StateRef) (*State, error)
	// Del hard deletes current state. State may be recovered via the Event store.
	Del(context.Context, *StateRef) (*empty.Empty, error)
	// Search queries state belonging to a particular domain & of a specific type
	Search(context.Context, *SearchStateOpts) (*StateValues, error)
}

StateServiceServer is the server API for StateService service.

type StateValues added in v0.5.0

type StateValues struct {
	StateValues []*State `protobuf:"bytes,1,rep,name=state_values,json=stateValues,proto3" json:"state_values,omitempty"`
	// contains filtered or unexported fields
}

States is an array of State

func (*StateValues) Descriptor deprecated added in v0.5.0

func (*StateValues) Descriptor() ([]byte, []int)

Deprecated: Use StateValues.ProtoReflect.Descriptor instead.

func (*StateValues) GetStateValues added in v0.5.0

func (x *StateValues) GetStateValues() []*State

func (*StateValues) ProtoMessage added in v0.5.0

func (*StateValues) ProtoMessage()

func (*StateValues) ProtoReflect added in v0.5.0

func (x *StateValues) ProtoReflect() protoreflect.Message

func (*StateValues) Reset added in v0.5.0

func (x *StateValues) Reset()

func (*StateValues) String added in v0.5.0

func (x *StateValues) String() string

func (*StateValues) Validate added in v0.5.0

func (this *StateValues) Validate() error

type StreamOpts

type StreamOpts struct {

	// the domain of the application state value (ex: acme) that triggered the event
	Domain string `protobuf:"bytes,1,opt,name=domain,proto3" json:"domain,omitempty"`
	// the type of the application state value (ex: user) that triggered the event
	Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
	// contains filtered or unexported fields
}

StreamOpts are options for consumers looking to stream events

func (*StreamOpts) Descriptor deprecated

func (*StreamOpts) Descriptor() ([]byte, []int)

Deprecated: Use StreamOpts.ProtoReflect.Descriptor instead.

func (*StreamOpts) GetDomain added in v0.4.0

func (x *StreamOpts) GetDomain() string

func (*StreamOpts) GetType

func (x *StreamOpts) GetType() string

func (*StreamOpts) ProtoMessage

func (*StreamOpts) ProtoMessage()

func (*StreamOpts) ProtoReflect

func (x *StreamOpts) ProtoReflect() protoreflect.Message

func (*StreamOpts) Reset

func (x *StreamOpts) Reset()

func (*StreamOpts) String

func (x *StreamOpts) String() string

func (*StreamOpts) Validate

func (this *StreamOpts) Validate() error

type UnimplementedEventServiceServer added in v0.4.0

type UnimplementedEventServiceServer struct {
}

UnimplementedEventServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedEventServiceServer) Search added in v0.4.0

func (*UnimplementedEventServiceServer) Stream added in v0.4.0

type UnimplementedStateServiceServer added in v0.5.0

type UnimplementedStateServiceServer struct {
}

UnimplementedStateServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedStateServiceServer) Del added in v0.5.0

func (*UnimplementedStateServiceServer) Get added in v0.5.0

func (*UnimplementedStateServiceServer) Search added in v0.5.0

func (*UnimplementedStateServiceServer) Set added in v0.5.0

Jump to

Keyboard shortcuts

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