api

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: Apache-2.0 Imports: 29 Imported by: 6

Documentation

Index

Constants

View Source
const IDField = "id"

IDField is the name of the ID field used in protobuf messages

View Source
const PageTokenField = "page_token"

PageTokenField is the protobuf field that contains our page token.

Variables

View Source
var (
	ErrInvalidColumnName = errors.New("column name is invalid")
	ErrEmptyRequest      = errors.New("empty request")
)
View Source
var (
	ErrMissingInitFunc = errors.New("missing stream initializer function")
)
View Source
var File_api_page_token_proto protoreflect.FileDescriptor

Functions

func DefaultGrpcDialOptions

func DefaultGrpcDialOptions(hostport string, s UsesAuthorizer, additionalOpts ...grpc.DialOption) (opts []grpc.DialOption)

DefaultGrpcDialOptions returns a set of sensible default list of grpc.DialOption values. It includes transport credentials and configures per-RPC credentials using an authorizer, if one is configured.

func ListAllPaginated added in v1.4.6

func ListAllPaginated[ResponseType PaginatedResponse, RequestType PaginatedRequest, ResultType any](
	req RequestType, list func(context.Context, RequestType, ...grpc.CallOption) (ResponseType, error),
	getter func(res ResponseType) []ResultType) (results []ResultType, err error)

ListAllPaginated invokes a List gRPC function that supports pagination, fetches all pages using individual calls and finally combines all results of all pages into a single slice. It executes the function specified in list using the req of RequestType. Afterwards, the function getter is executed to transform the response of the list calls into the results slice.

func StatusFromWrappedError added in v1.4.14

func StatusFromWrappedError(err error) (s *status.Status, ok bool)

StatusFromWrappedError attempts to recover a status.Status from a wrapped error message. This is necessary, because the underlying RPC error might be wrapped in multiple layers of additional error messages and status.FromError only checks the error itself.

Types

type Authorizer

type Authorizer interface {
	credentials.PerRPCCredentials
	oauth2.TokenSource
}

Authorizer represents an interface which provides a token used for authenticating a client in server-client communication. More specifically, this interfaces requires credentials.PerRPCCredentials, which enables this to be used by a gRPC client to communicate with a gRPC server that requires per-RPC credentials.

func NewOAuthAuthorizerFromClientCredentials

func NewOAuthAuthorizerFromClientCredentials(config *clientcredentials.Config) Authorizer

NewOAuthAuthorizerFromClientCredentials creates a new authorizer based on an OAuth 2.0 client credentials.

func NewOAuthAuthorizerFromConfig

func NewOAuthAuthorizerFromConfig(config *oauth2.Config, token *oauth2.Token) Authorizer

NewOAuthAuthorizerFromConfig creates a new authorizer based on an OAuth 2.0 config.

type InitFuncOf added in v1.4.4

type InitFuncOf[StreamType grpc.ClientStream] func(target string, additionalOpts ...grpc.DialOption) (stream StreamType, err error)

InitFuncOf describes a function with type parameters that creates any kind of stream towards a gRPC server specified in target and returns the stream or an error. Additional gRPC dial options can be specified in additionalOpts.

type PageToken added in v1.4.6

type PageToken struct {
	Start int64 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`
	Size  int32 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"`
	// contains filtered or unexported fields
}

func DecodePageToken added in v1.4.6

func DecodePageToken(b64token string) (t *PageToken, err error)

DecodePageToken decodes a PageToken out of a base 64 URL encoded string.

func (*PageToken) Descriptor deprecated added in v1.4.6

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

Deprecated: Use PageToken.ProtoReflect.Descriptor instead.

func (*PageToken) Encode added in v1.4.6

func (t *PageToken) Encode() (b64token string, err error)

Encode encodes this page token into a base64 URL encoded string.

func (*PageToken) GetSize added in v1.4.6

func (x *PageToken) GetSize() int32

func (*PageToken) GetStart added in v1.4.6

func (x *PageToken) GetStart() int64

func (*PageToken) ProtoMessage added in v1.4.6

func (*PageToken) ProtoMessage()

func (*PageToken) ProtoReflect added in v1.4.6

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

func (*PageToken) Reset added in v1.4.6

func (x *PageToken) Reset()

func (*PageToken) String added in v1.4.6

func (x *PageToken) String() string

func (*PageToken) Validate added in v1.7.0

func (m *PageToken) Validate() error

Validate checks the field values on PageToken with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*PageToken) ValidateAll added in v1.7.0

func (m *PageToken) ValidateAll() error

ValidateAll checks the field values on PageToken with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in PageTokenMultiError, or nil if none found.

type PageTokenMultiError added in v1.7.0

type PageTokenMultiError []error

PageTokenMultiError is an error wrapping multiple validation errors returned by PageToken.ValidateAll() if the designated constraints aren't met.

func (PageTokenMultiError) AllErrors added in v1.7.0

func (m PageTokenMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (PageTokenMultiError) Error added in v1.7.0

func (m PageTokenMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type PageTokenValidationError added in v1.7.0

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

PageTokenValidationError is the validation error returned by PageToken.Validate if the designated constraints aren't met.

func (PageTokenValidationError) Cause added in v1.7.0

func (e PageTokenValidationError) Cause() error

Cause function returns cause value.

func (PageTokenValidationError) Error added in v1.7.0

func (e PageTokenValidationError) Error() string

Error satisfies the builtin error interface

func (PageTokenValidationError) ErrorName added in v1.7.0

func (e PageTokenValidationError) ErrorName() string

ErrorName returns error name.

func (PageTokenValidationError) Field added in v1.7.0

func (e PageTokenValidationError) Field() string

Field function returns field value.

func (PageTokenValidationError) Key added in v1.7.0

Key function returns key value.

func (PageTokenValidationError) Reason added in v1.7.0

func (e PageTokenValidationError) Reason() string

Reason function returns reason value.

type PaginatedRequest added in v1.4.6

type PaginatedRequest interface {
	GetPageToken() string
	GetPageSize() int32
	GetOrderBy() string // For ordering
	GetAsc() bool       // For ordering
	proto.Message
}

PaginatedRequest contains the typical parameters for a paginated request, usually a request for a List gRPC call.

type PaginatedResponse added in v1.4.6

type PaginatedResponse interface {
	GetNextPageToken() string
}

PaginatedResponse contains the typical parameters for a paginated response, usually a response for a List gRPC call.

type StreamChannelOf added in v1.4.4

type StreamChannelOf[StreamType grpc.ClientStream, MsgType proto.Message] struct {
	// contains filtered or unexported fields
}

StreamChannelOf provides a channel around a connection to a grpc.ClientStream to send messages of type MsgType to that particular stream, using an internal go routine. This is necessary, because gRPC does not allow sending to a stream from multiple goroutines directly.

func (*StreamChannelOf[StreamType, MsgType]) Send added in v1.4.4

func (c *StreamChannelOf[StreamType, MsgType]) Send(msg MsgType)

Send sends the message into the stream via the channel. Since this uses the receive operator on the channel, this function may block until the message is received on the sendLoop of this StreamChannelOf or if the buffer of the channel is full.

type StreamsOf added in v1.4.4

type StreamsOf[StreamType grpc.ClientStream, MsgType proto.Message] struct {
	// contains filtered or unexported fields
}

StreamsOf handles stream channels to multiple gRPC servers, identified by a unique target (usually host and port). Since gRPC does only allow to send to a stream using one goroutine, each stream provides a go channel that can be used to send messages to the particular stream.

A stream for a given target can be retrieved with the GetStream function, which automatically initializes the stream if it does not exist.

func NewStreamsOf added in v1.4.4

func NewStreamsOf[StreamType grpc.ClientStream, MsgType proto.Message](opts ...StreamsOfOption[StreamType, MsgType]) (s *StreamsOf[StreamType, MsgType])

NewStreamsOf creates a new StreamsOf object and initializes all the necessary objects for it.

func (*StreamsOf[StreamType, MsgType]) GetStream added in v1.4.4

func (s *StreamsOf[StreamType, MsgType]) GetStream(target string, component string, init InitFuncOf[StreamType], opts ...grpc.DialOption) (c *StreamChannelOf[StreamType, MsgType], err error)

GetStream tries to retrieve a stream for the given target and component. If no stream exists, it tries to create a new stream using the supplied init function. An error is returned if the initialization is not successful.

type StreamsOfOption added in v1.4.4

type StreamsOfOption[StreamType grpc.ClientStream, MsgType proto.Message] func(*StreamsOf[StreamType, MsgType])

StreamsOfOption is a functional option type to configure the StreamOf type.

func WithLogger added in v1.4.4

func WithLogger[StreamType grpc.ClientStream, MsgType proto.Message](log *logrus.Entry) StreamsOfOption[StreamType, MsgType]

WithLogger can be used to specify a dedicated logger entry which is used for logging. Otherwise, the default logging entry of logrus is used.

type UsesAuthorizer

type UsesAuthorizer interface {
	SetAuthorizer(auth Authorizer)
	Authorizer() Authorizer
}

UsesAuthorizer is an interface to denote that a struct is willing to accept and use an Authorizer

Directories

Path Synopsis
Package assessment is a reverse proxy.
Package assessment is a reverse proxy.
Package discovery is a reverse proxy.
Package discovery is a reverse proxy.
Package evidence is a reverse proxy.
Package evidence is a reverse proxy.
Package orchestrator is a reverse proxy.
Package orchestrator is a reverse proxy.

Jump to

Keyboard shortcuts

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