tunnel

package
v16.4.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 29 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, 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.
	Done()
}

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.
	// ctx can be used to unblock the method if the tunnel is not being used already.
	// ctx should be a child of the server's context.
	HandleTunnel(ctx context.Context, agentInfo *api.AgentInfo, server rpc.ReverseTunnel_ConnectServer) error
}

type KasUrlsByAgentIdCallback

type KasUrlsByAgentIdCallback func(kasUrl string) (bool, 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 calls the callback with the list of kas URLs for a particular agent id.
	// Safe for concurrent use.
	KasUrlsByAgentId(ctx context.Context, agentId int64, cb KasUrlsByAgentIdCallback) error
}

type RedisTracker

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

func NewRedisTracker

func NewRedisTracker(log *zap.Logger, api modshared.Api, client rueidis.Client, agentKeyPrefix string,
	ttl time.Duration, ownPrivateApiUrl string) *RedisTracker

func (*RedisTracker) GC

func (t *RedisTracker) GC() func(context.Context) (int, error)

func (*RedisTracker) KasUrlsByAgentId

func (t *RedisTracker) KasUrlsByAgentId(ctx context.Context, agentId int64, cb KasUrlsByAgentIdCallback) error

func (*RedisTracker) Refresh

func (t *RedisTracker) Refresh(ctx context.Context, nextRefresh time.Time) error

func (*RedisTracker) RegisterTunnel

func (t *RedisTracker) RegisterTunnel(ctx context.Context, 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, agentId int64) error
	// UnregisterTunnel unregisters tunnel with the tracker.
	UnregisterTunnel(ctx context.Context, agentId int64) error
	// GC deletes expired tunnels from the underlying storage.
	GC() func(context.Context) (int, error)
	// Refresh refreshes registered tunnels in the underlying storage.
	Refresh(ctx context.Context, nextRefresh time.Time) 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, gcPeriod time.Duration,
	newTunnelTracker func() 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(ctx context.Context, agentInfo *api.AgentInfo, server rpc.ReverseTunnel_ConnectServer) error

func (*Registry) KasUrlsByAgentId

func (r *Registry) KasUrlsByAgentId(ctx context.Context, agentId int64, cb KasUrlsByAgentIdCallback) 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.
	Done()
}

Jump to

Keyboard shortcuts

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