dispatch

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxDepth = errors.New("max depth exceeded: this usually indicates a recursive or too deep data dependency")

ErrMaxDepth is returned from CheckDepth when the max depth is exceeded.

Functions

func AddResponseMetadata added in v1.12.0

func AddResponseMetadata(existing *v1.ResponseMeta, incoming *v1.ResponseMeta)

AddResponseMetadata adds the metadata found in the incoming metadata to the existing metadata, *modifying it in place*.

func CheckDepth

func CheckDepth(ctx context.Context, req HasMetadata) error

CheckDepth returns ErrMaxDepth if there is insufficient depth remaining to dispatch.

func ConvertDispatchDebugInformation added in v1.11.0

func ConvertDispatchDebugInformation(ctx context.Context, metadata *dispatch.ResponseMeta, reader datastore.Reader) (*v1.DebugInformation, error)

ConvertDispatchDebugInformation converts dispatch debug information found in the response metadata into DebugInformation returnable to the API.

Types

type Check

type Check interface {
	// DispatchCheck submits a single check request and returns its result.
	DispatchCheck(ctx context.Context, req *v1.DispatchCheckRequest) (*v1.DispatchCheckResponse, error)
}

Check interface describes just the methods required to dispatch check requests.

type CollectingDispatchStream added in v1.8.0

type CollectingDispatchStream[T any] struct {
	// contains filtered or unexported fields
}

CollectingDispatchStream is a dispatch stream that collects results in memory.

func NewCollectingDispatchStream added in v1.8.0

func NewCollectingDispatchStream[T any](ctx context.Context) *CollectingDispatchStream[T]

NewCollectingDispatchStream creates a new CollectingDispatchStream.

func (*CollectingDispatchStream[T]) Context added in v1.8.0

func (s *CollectingDispatchStream[T]) Context() context.Context

func (*CollectingDispatchStream[T]) Publish added in v1.8.0

func (s *CollectingDispatchStream[T]) Publish(result T) error

func (*CollectingDispatchStream[T]) Results added in v1.8.0

func (s *CollectingDispatchStream[T]) Results() []T

type Dispatcher

type Dispatcher interface {
	Check
	Expand
	Lookup
	ReachableResources
	LookupSubjects

	// Close closes the dispatcher.
	Close() error

	// IsReady returns true when dispatcher is able to respond to requests
	IsReady() bool
}

Dispatcher interface describes a method for passing subchecks off to additional machines.

type Expand

type Expand interface {
	// DispatchExpand submits a single expand request and returns its result.
	DispatchExpand(ctx context.Context, req *v1.DispatchExpandRequest) (*v1.DispatchExpandResponse, error)
}

Expand interface describes just the methods required to dispatch expand requests.

type HandlingDispatchStream added in v1.12.0

type HandlingDispatchStream[T any] struct {
	// contains filtered or unexported fields
}

HandlingDispatchStream is a dispatch stream that executes a handler for each item published. It uses an internal mutex to ensure it is thread safe.

func (*HandlingDispatchStream[T]) Context added in v1.12.0

func (s *HandlingDispatchStream[T]) Context() context.Context

func (*HandlingDispatchStream[T]) Publish added in v1.12.0

func (s *HandlingDispatchStream[T]) Publish(result T) error

type HasMetadata

type HasMetadata interface {
	zerolog.LogObjectMarshaler

	GetMetadata() *v1.ResolverMeta
}

HasMetadata is an interface for requests containing resolver metadata.

type Lookup

type Lookup interface {
	// DispatchLookup submits a single lookup request and returns its result.
	DispatchLookup(ctx context.Context, req *v1.DispatchLookupRequest) (*v1.DispatchLookupResponse, error)
}

Lookup interface describes just the methods required to dispatch lookup requests.

type LookupSubjects added in v1.12.0

type LookupSubjects interface {
	// DispatchLookupSubjects submits a single lookup subjects request, writing its results to the specified stream.
	DispatchLookupSubjects(
		req *v1.DispatchLookupSubjectsRequest,
		stream LookupSubjectsStream,
	) error
}

LookupSubjects interface describes just the methods required to dispatch lookup subjects requests.

type LookupSubjectsStream added in v1.12.0

type LookupSubjectsStream = Stream[*v1.DispatchLookupSubjectsResponse]

LookupSubjectsStream is an alias for the stream to which found subjects will be written.

type ReachableResources added in v1.8.0

type ReachableResources interface {
	// DispatchReachableResources submits a single reachable resources request, writing its results to the specified stream.
	DispatchReachableResources(
		req *v1.DispatchReachableResourcesRequest,
		stream ReachableResourcesStream,
	) error
}

ReachableResources interface describes just the methods required to dispatch reachable resources requests.

type ReachableResourcesStream added in v1.8.0

type ReachableResourcesStream = Stream[*v1.DispatchReachableResourcesResponse]

ReachableResourcesStream is an alias for the stream to which reachable resources will be written.

type Stream added in v1.8.0

type Stream[T any] interface {
	// Publish publishes the result to the stream.
	Publish(T) error

	// Context returns the context for the stream.
	Context() context.Context
}

Stream defines the interface generically matching a streaming dispatch response.

func NewHandlingDispatchStream added in v1.12.0

func NewHandlingDispatchStream[T any](ctx context.Context, processor func(result T) error) Stream[T]

NewHandlingDispatchStream returns a new handling dispatch stream.

func StreamWithContext added in v1.8.0

func StreamWithContext[T any](context context.Context, stream Stream[T]) Stream[T]

StreamWithContext returns the given dispatch stream, wrapped to return the given context.

func WrapGRPCStream added in v1.8.0

func WrapGRPCStream[R any, S grpcStream[R]](grpcStream S) Stream[R]

WrapGRPCStream wraps a gRPC result stream with a concurrent-safe dispatch stream. This is necessary because gRPC response streams are *not concurrent safe*. See: https://groups.google.com/g/grpc-io/c/aI6L6M4fzQ0?pli=1

type WrappedDispatchStream added in v1.8.0

type WrappedDispatchStream[T any] struct {
	Stream    Stream[T]
	Ctx       context.Context
	Processor func(result T) (T, bool, error)
}

WrappedDispatchStream is a dispatch stream that wraps another dispatch stream, and performs an operation on each result before puppeting back up to the parent stream.

func (*WrappedDispatchStream[T]) Context added in v1.8.0

func (s *WrappedDispatchStream[T]) Context() context.Context

func (*WrappedDispatchStream[T]) Publish added in v1.8.0

func (s *WrappedDispatchStream[T]) Publish(result T) error

Directories

Path Synopsis
Package combined implements a dispatcher that combines caching, redispatching and optional cluster dispatching.
Package combined implements a dispatcher that combines caching, redispatching and optional cluster dispatching.

Jump to

Keyboard shortcuts

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