router

package
v17.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetRoutingMetadata

func SetRoutingMetadata(md metadata.MD, agentID int64) metadata.MD

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) CachedGatewayURLs

func (q *AggregatingQuerier) CachedGatewayURLs(agentID int64) []string

func (*AggregatingQuerier) PollGatewayURLs

func (q *AggregatingQuerier) PollGatewayURLs(ctx context.Context, agentID int64, cb tunserver.PollGatewayURLsCallback)

func (*AggregatingQuerier) Run

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 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, m otelmetric.Meter) (*RedisTracker, error)

func (*RedisTracker) GC

func (t *RedisTracker) GC(ctx context.Context, agentIDs []int64) (int, error)

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
	// GC deletes expired tunnels from the underlying storage.
	GC(ctx context.Context, agentIDs []int64) (int, 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, gcPeriod, ttl time.Duration,
	tunnelTracker Tracker) *Registry

func (*Registry) FindTunnel

func (r *Registry) FindTunnel(ctx context.Context, agentID int64, service, method string) (bool, tunserver.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 RouterPlugin

type RouterPlugin struct {
	KASPool               grpctool.PoolInterface
	GatewayQuerier        tunserver.PollingGatewayURLQuerier
	TunnelRegistry        *Registry
	OwnPrivateAPIURL      string
	PollConfig            retry.PollConfigFactory
	TryNewGatewayInterval time.Duration
}

func (*RouterPlugin) FindTunnel

func (p *RouterPlugin) FindTunnel(stream grpc.ServerStream, rpcAPI modshared.RPCAPI) (bool, *zap.Logger, tunserver.FindHandle, error)

func (*RouterPlugin) GatewayFinderForStream

func (p *RouterPlugin) GatewayFinderForStream(stream grpc.ServerStream, rpcAPI modshared.RPCAPI) (tunserver.GatewayFinder, *zap.Logger, int64, error)

type Tracker

type Tracker interface {
	Registerer
	Querier
}

Jump to

Keyboard shortcuts

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