server

package
v16.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregatingQuerier

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

AggregatingQuerier groups polling requests.

func NewAggregatingQuerier

func NewAggregatingQuerier(log *zap.Logger, delegate Querier, api modshared.Api, tracer trace.Tracer, pollConfig retry.PollConfigFactory, gcPeriod time.Duration) *AggregatingQuerier

func (*AggregatingQuerier) CachedKasUrlsByAgentId

func (q *AggregatingQuerier) CachedKasUrlsByAgentId(agentId int64) []string

func (*AggregatingQuerier) PollKasUrlsByAgentId

func (q *AggregatingQuerier) PollKasUrlsByAgentId(ctx context.Context, agentId int64, cb PollKasUrlsByAgentIdCallback)

func (*AggregatingQuerier) Run

type DataCallback

type DataCallback interface {
	Header(map[string]*prototool.Values) error
	Message([]byte) error
	Trailer(map[string]*prototool.Values) error
	Error(*statuspb.Status) error
}

type FindHandle

type FindHandle interface {
	// Get finds a tunnel to an agentk.
	// It waits for a matching tunnel to proxy a connection through. When a matching tunnel is found, it is returned.
	// It returns gRPC status errors only, ready to return from RPC handler.
	Get(ctx context.Context) (Tunnel, error)
	// Done must be called to free resources of this FindHandle instance.
	// ctx is used for tracing only.
	Done(ctx context.Context)
}

type Finder

type Finder interface {
	// FindTunnel starts searching for a tunnel to a matching agentk.
	// Found tunnel is:
	// - to an agent with provided id.
	// - supports handling provided gRPC service and method.
	// Tunnel found boolean indicates whether a suitable tunnel is immediately available from the
	// returned FindHandle object.
	FindTunnel(ctx context.Context, agentId int64, service, method string) (bool, FindHandle)
}

type Handler

type Handler interface {
	// HandleTunnel is called with server-side interface of the reverse tunnel.
	// It registers the tunnel and blocks, waiting for a request to proxy through the tunnel.
	// The method returns the error value to return to gRPC framework.
	// ageCtx can be used to unblock the method if the tunnel is not being used already.
	HandleTunnel(ageCtx context.Context, agentInfo *api.AgentInfo, server rpc.ReverseTunnel_ConnectServer) error
}

type PollKasUrlsByAgentIdCallback

type PollKasUrlsByAgentIdCallback func(kasUrls []string)

PollKasUrlsByAgentIdCallback is called periodically with found kas URLs for a particular agent id.

type PollingQuerier

type PollingQuerier interface {
	PollKasUrlsByAgentId(ctx context.Context, agentId int64, cb PollKasUrlsByAgentIdCallback)
	CachedKasUrlsByAgentId(agentId int64) []string
}

type Querier

type Querier interface {
	// KasUrlsByAgentId returns the list of kas URLs for a particular agent id.
	// A partial list may be returned together with an error.
	// Safe for concurrent use.
	KasUrlsByAgentId(ctx context.Context, agentId int64) ([]string, error)
}

type RedisTracker

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

func NewRedisTracker

func NewRedisTracker(client rueidis.Client, agentKeyPrefix string, ownPrivateApiUrl string) *RedisTracker

func (*RedisTracker) KasUrlsByAgentId

func (t *RedisTracker) KasUrlsByAgentId(ctx context.Context, agentId int64) ([]string, error)

func (*RedisTracker) Refresh

func (t *RedisTracker) Refresh(ctx context.Context, ttl time.Duration, agentIds ...int64) error

func (*RedisTracker) RegisterTunnel

func (t *RedisTracker) RegisterTunnel(ctx context.Context, ttl time.Duration, agentId int64) error

func (*RedisTracker) UnregisterTunnel

func (t *RedisTracker) UnregisterTunnel(ctx context.Context, agentId int64) error

type Registerer

type Registerer interface {
	// RegisterTunnel registers tunnel with the tracker.
	RegisterTunnel(ctx context.Context, ttl time.Duration, agentId int64) error
	// UnregisterTunnel unregisters tunnel with the tracker.
	UnregisterTunnel(ctx context.Context, agentId int64) error
	// Refresh refreshes registered tunnels in the underlying storage.
	Refresh(ctx context.Context, ttl time.Duration, agentIds ...int64) error
}

Registerer allows to register and unregister tunnels. Caller is responsible for periodically calling GC() and Refresh(). Not safe for concurrent use.

type Registry

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

func NewRegistry

func NewRegistry(log *zap.Logger, api modshared.Api, tracer trace.Tracer, refreshPeriod, ttl time.Duration,
	tunnelTracker Tracker) (*Registry, error)

func (*Registry) FindTunnel

func (r *Registry) FindTunnel(ctx context.Context, agentId int64, service, method string) (bool, FindHandle)

func (*Registry) HandleTunnel

func (r *Registry) HandleTunnel(ageCtx context.Context, agentInfo *api.AgentInfo, server rpc.ReverseTunnel_ConnectServer) error

func (*Registry) KasUrlsByAgentId

func (r *Registry) KasUrlsByAgentId(ctx context.Context, agentId int64) ([]string, error)

func (*Registry) Run

func (r *Registry) Run(ctx context.Context) error

type RpcApi

type RpcApi interface {
	HandleIoError(log *zap.Logger, msg string, err error) error
}

type Tracker

type Tracker interface {
	Registerer
	Querier
}

type Tunnel

type Tunnel interface {
	// ForwardStream performs bi-directional message forwarding between incomingStream and the tunnel.
	// cb is called with header, messages and trailer coming from the tunnel. It's the callers
	// responsibility to forward them into the incomingStream.
	ForwardStream(log *zap.Logger, rpcApi RpcApi, incomingStream grpc.ServerStream, cb DataCallback) error
	// Done must be called when the caller is done with the Tunnel.
	// ctx is used for tracing only.
	Done(ctx context.Context)
}

Jump to

Keyboard shortcuts

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