Documentation
¶
Index ¶
Constants ¶
const DefaultPollInterval = 1 * time.Second
DefaultPollInterval how often the dispatcher polls for dispatchable packets.
Variables ¶
var ErrTransferAlreadyInPipeline = errors.New("transfer already in pipeline")
ErrTransferAlreadyInPipeline the transfer is already being relayed.
Functions ¶
This section is empty.
Types ¶
type Deduper ¶
type Deduper struct {
// contains filtered or unexported fields
}
Deduper rejects transfers already in flight in the wrapped pipeline. It consumes the pipeline's output itself to learn when transfers leave. A transfer that left stays rejected until Release: a packet read before it left may predate its last writes.
func NewDeduper ¶
func NewDeduper(pl pipeline.TransferPipeline) *Deduper
type DispatcherStorage ¶
type DispatcherStorage interface {
ListDispatchablePackets(ctx context.Context) ([]store.Packet, error)
UpdatePacketStatus(ctx context.Context, key store.PacketKey, status store.RelayStatus) error
}
DispatcherStorage the persistence used by the dispatcher.
type PipelineSet ¶
type PipelineSet struct {
// contains filtered or unexported fields
}
PipelineSet creates and caches one pipeline per route.
func NewPipelineSet ¶
func (*PipelineSet) Close ¶
func (s *PipelineSet) Close()
Close closes every pipeline. The context the pipelines were created with must already be canceled: pipeline outputs only close on cancellation.
func (*PipelineSet) Pipeline ¶
func (s *PipelineSet) Pipeline(ctx context.Context, tr *processors.Transfer) (pipeline.TransferPipeline, error)
Pipeline returns the pipeline for the transfer's route, creating it on first use. Transfers whose source client has no configured route error.
func (*PipelineSet) Release ¶
func (s *PipelineSet) Release()
func (*PipelineSet) Routes ¶
func (s *PipelineSet) Routes() []processors.Route
Routes returns every configured relay route, in both directions.
type Pipelines ¶
type Pipelines interface {
Pipeline(ctx context.Context, tr *processors.Transfer) (pipeline.TransferPipeline, error)
// Release lets the transfers that have left their pipelines be pushed
// again.
Release()
Routes() []processors.Route
Close()
}
Pipelines identifies the pipeline a transfer is relayed through.
type RelayDispatcher ¶
type RelayDispatcher struct {
// contains filtered or unexported fields
}
RelayDispatcher polls the store for dispatchable packets and routes them to their pipelines. The relay API couples to the dispatcher through the store: it inserts packets, the dispatcher picks them up on the next poll.
func NewRelayDispatcher ¶
func NewRelayDispatcher( storage DispatcherStorage, pipelines Pipelines, pollInterval time.Duration, logger *slog.Logger, ) *RelayDispatcher
func (*RelayDispatcher) Start ¶
func (d *RelayDispatcher) Start() error
Start begins the dispatch loop in its own goroutine. Polls for dispatchable packets until Stop is called.
func (*RelayDispatcher) Stop ¶
func (d *RelayDispatcher) Stop() error
Stop cancels the dispatch loop and blocks until it has exited and every pipeline it created is closed.
func (*RelayDispatcher) SubmitTransfer ¶
func (d *RelayDispatcher) SubmitTransfer(ctx context.Context, tr *processors.Transfer) error
SubmitTransfer routes the transfer to its pipeline and pushes it.
func (*RelayDispatcher) SubmitWaitingDispatchablePackets ¶
func (d *RelayDispatcher) SubmitWaitingDispatchablePackets(ctx context.Context) error
SubmitWaitingDispatchablePackets pushes every selected non-terminal packet into its pipeline. Packets that fail to submit for anything other than already being in flight are marked failed: submission only fails on configuration errors that will not resolve by retrying.