broker

package
v0.0.0-...-44018a4 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToService

func ConnectToService(ctx context.Context, brokerUrl, prefix, originName string) (conn net.Conn, err error)

Given an origin's broker URL, return a connected socket to the origin

func InitializeBrokerClient

func InitializeBrokerClient(ctx context.Context, egrp *errgroup.Group, router *gin.Engine)

InitializeBrokerClient sets up everything needed for a service to use brokered connections (as the initiator, not as the broker itself).

func LaunchNamespaceKeyMaintenance

func LaunchNamespaceKeyMaintenance(ctx context.Context, egrp *errgroup.Group)

Launches a background goroutine that periodically expires the namespace key cache

func LaunchRequestMonitor

func LaunchRequestMonitor(ctx context.Context, egrp *errgroup.Group, sType server_structs.ServerType, privateName, registeredPrefix string, resultChan chan any) (err error)

Launch a goroutine that polls the broker endpoint for reversal requests The returned channel will produce listeners that are "one shot"; it's a TLS listener where you can invoke "Accept" once before it automatically closes itself. It is the result of a successful connection reversal to a cache.

The request monitor is used by the "private service" (the service behind the firewall) to know when to setup connections requested by the "public service" (e.g., a cache).

The registeredPrefix parameter, if non-empty, specifies the namespace prefix to use for token authentication. This should be the prefix that the service is registered under in the registry. If empty, the prefix is constructed from privateName. This is useful when polling for multiple addresses (e.g., both web URL and XRootD URL) but authenticating with a single registered namespace.

func RegisterBroker

func RegisterBroker(ctx context.Context, router *gin.RouterGroup)

Register the central broker functionality with the gin router.

Typically, this is done by the director; two APIs are exposed:

  • `retrieve`: Services needing connection brokering (e.g., origins behind a firewall) will long-poll this endpoint to retrieve any connection brokering requests from a public service (e.g., a cache).
  • `reverse`: Invoked by a public service (e.g., a cache) that would like to connect to a service behind a firewall (e.g., an origin). Official request for the origin to make a connection.

func RegisterBrokerCallback

func RegisterBrokerCallback(ctx context.Context, router *gin.RouterGroup)

Register the HTTP handlers for the callback to a cache

func Reset

func Reset()

Reset the global state of the module; it is assumed this is invoked from unit tests only without concurrency issues.

func ResetState

func ResetState()

ResetState clears all pending broker requests; used for testing

Types

type BrokerDialer

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

BrokerDialer is a dialer that can use the broker functionality to connect to a remote service.

func NewBrokerDialer

func NewBrokerDialer(ctx context.Context, egrp *errgroup.Group) *BrokerDialer

NewBrokerDialer creates a new BrokerDialer.

func (*BrokerDialer) DialContext

func (d *BrokerDialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error)

DialContext dials a connection to the given network and address using the broker.

func (*BrokerDialer) HasBrokerEndpoint

func (d *BrokerDialer) HasBrokerEndpoint(addr string) bool

HasBrokerEndpoint returns true if the dialer knows about a broker endpoint for the given address.

func (*BrokerDialer) UseBroker

func (d *BrokerDialer) UseBroker(serverType server_structs.ServerType, name, brokerUrl, prefix string)

Set the dialer to use `brokerUrl` as the broker endpoint for the service `name`.

type BrokerListener

type BrokerListener struct {
	Listener  net.Listener
	RequestId string
}

BrokerListener wraps a net.Listener with broker connection metadata

Jump to

Keyboard shortcuts

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