 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataCallback ¶
type ErrorHandler ¶
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 GatewayFinder ¶
type GatewayFinder[T Target] interface { Find(ctx context.Context) (ReadyGateway[T], error) }
func NewGatewayFinder ¶
func NewGatewayFinder[T Target, K RoutingKey](outgoingCtx context.Context, log *slog.Logger, gatewayPool grpctool.PoolInterface[T], gatewayQuerier PollingGatewayURLQuerier[T, K], errorHandler ErrorHandler, fullMethod string, ownPrivateAPIURL T, key K, pollConfig retry.PollConfigFactory, tryNewGatewayInterval time.Duration) GatewayFinder[T]
type PollGatewayURLsCallback ¶
type PollGatewayURLsCallback[T Target] func(gatewayURLs []T)
PollGatewayURLsCallback is called periodically with found gateway tunserver URLs for a particular agent key.
type PollingGatewayURLQuerier ¶
type PollingGatewayURLQuerier[T Target, K RoutingKey] interface { PollGatewayURLs(ctx context.Context, key K, cb PollGatewayURLsCallback[T]) CachedGatewayURLs(key K) []T }
type ReadyGateway ¶
type ReadyGateway[T Target] struct { URL T Stream grpc.ClientStream StreamCancel context.CancelFunc Codec encoding.CodecV2 }
type Router ¶
type Router[T Target, K RoutingKey] struct { Plugin RouterPlugin[T, K] // PrivateAPIServer is the gRPC server that other kas instances can talk to. // Request handlers can obtain the per-request logger using modshared.RPCAPIFromContext(requestContext). PrivateAPIServer grpc.ServiceRegistrar }
Router routes traffic from kas to another kas to agentk. routing kas -> gateway kas -> agentk
func (*Router[T, K]) RegisterTunclientAPI ¶
func (r *Router[T, K]) RegisterTunclientAPI(desc *grpc.ServiceDesc)
type RouterPlugin ¶
type RouterPlugin[T Target, K RoutingKey] interface { // FindReadyGateway finds a ready gateway tunserver to route the request through. // It returns an error, compatible with gRPC status package. FindReadyGateway(ctx context.Context, method string) (ReadyGateway[T], *slog.Logger, K, error) // FindTunnel starts searching for a tunnel to a matching tunclient. // Tunnel found boolean indicates whether a suitable tunnel is immediately available from the // returned FindHandle object. FindTunnel(grpc.ServerStream) (bool, *slog.Logger, FindHandle, error) // PrepareStreamForForwarding is used to perform any actions, like wrapping, on the stream just before // forwarding it to tunclient. // Returned error is compatible with gRPC-status error. PrepareStreamForForwarding(stream grpc.ServerStream) (grpc.ServerStream, error) }
type RoutingClientConn ¶
type RoutingClientConn[T Target, K RoutingKey] struct { ErrorHandler ErrorHandler Plugin RouterPlugin[T, K] }
func (*RoutingClientConn[T, K]) Invoke ¶
func (c *RoutingClientConn[T, K]) Invoke(ctx context.Context, method string, args, reply any, opts ...grpc.CallOption) error
func (*RoutingClientConn[T, K]) NewStream ¶
func (c *RoutingClientConn[T, K]) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
type RoutingKey ¶
type RoutingKey interface {
	comparable
	String() string
	LogAttr() slog.Attr
}
    type StateType ¶
type StateType int
const ( // StateReady - tunnel is owned by the registry and is ready to be found and used for forwarding. StateReady StateType // StateFound - tunnel is not owned by registry, was found and about to be used for forwarding. StateFound // StateForwarding - tunnel is not owned by registry, is being used for forwarding. StateForwarding // StateDone - tunnel is not owned by anyone, it has been used for forwarding, Done() has been called. StateDone // StateContextDone - tunnel is not owned by anyone, reverse tunnel's context signaled done in HandleTunnel(). StateContextDone )
type Target ¶
type Target interface {
	comparable
	String() string
}
    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 *slog.Logger, 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)
}
    type TunnelImpl ¶
type TunnelImpl[K RoutingKey] struct { Tunnel grpc.BidiStreamingServer[rpc.ConnectRequest, rpc.ConnectResponse] TunnelRetErr chan<- error RoutingKey K Descriptor *info.APIDescriptor State StateType OnForward func(*TunnelImpl[K]) error OnDone func(context.Context, *TunnelImpl[K]) }
func (*TunnelImpl[K]) Done ¶
func (t *TunnelImpl[K]) Done(ctx context.Context)
func (*TunnelImpl[K]) ForwardStream ¶
func (t *TunnelImpl[K]) ForwardStream(log *slog.Logger, incomingStream grpc.ServerStream, cb DataCallback) error
 Click to show internal directories. 
   Click to hide internal directories.