stream_relay

package
v0.34.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigID = ControllerID

ConfigID is the string used to identify this config object.

View Source
const ControllerID = "bifrost/stream/relay"

ControllerID identifies the relay controller.

Variables

View Source
var Version = semver.MustParse("0.0.1")

Version is the controller version.

Functions

This section is empty.

Types

type Config

type Config struct {

	// PeerId is the peer ID to listen for incoming streams.
	// Can be empty to accept any.
	PeerId string `protobuf:"bytes,1,opt,name=peer_id,json=peerId,proto3" json:"peerId,omitempty"`
	// ProtocolId is the protocol ID to filter incoming streams.
	// Cannot be empty.
	ProtocolId string `protobuf:"bytes,2,opt,name=protocol_id,json=protocolId,proto3" json:"protocolId,omitempty"`
	// TargetPeerId is the destination peer ID to relay to.
	// Cannot be empty.
	TargetPeerId string `protobuf:"bytes,3,opt,name=target_peer_id,json=targetPeerId,proto3" json:"targetPeerId,omitempty"`
	// TargetProtocolId is the destination protocol ID to relay to.
	// If unset, uses protocol_id.
	TargetProtocolId string `protobuf:"bytes,4,opt,name=target_protocol_id,json=targetProtocolId,proto3" json:"targetProtocolId,omitempty"`
	// contains filtered or unexported fields
}

Config configures the relay controller.

func (*Config) CloneMessageVT

func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*Config) CloneVT

func (m *Config) CloneVT() *Config

func (*Config) EqualMessageVT

func (this *Config) EqualMessageVT(thatMsg any) bool

func (*Config) EqualVT

func (this *Config) EqualVT(that *Config) bool

func (*Config) EqualsConfig

func (c *Config) EqualsConfig(c2 config.Config) bool

EqualsConfig checks if the config is equal to another.

func (*Config) GetConfigID

func (c *Config) GetConfigID() string

GetConfigID returns the unique string for this configuration type. This string is stored with the encoded config.

func (*Config) GetPeerId

func (x *Config) GetPeerId() string

func (*Config) GetProtocolId

func (x *Config) GetProtocolId() string

func (*Config) GetTargetPeerId

func (x *Config) GetTargetPeerId() string

func (*Config) GetTargetProtocolId

func (x *Config) GetTargetProtocolId() string

func (*Config) MarshalJSON

func (x *Config) MarshalJSON() ([]byte, error)

MarshalJSON marshals the Config to JSON.

func (*Config) MarshalProtoJSON

func (x *Config) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the Config message to JSON.

func (*Config) MarshalProtoText

func (x *Config) MarshalProtoText() string

func (*Config) MarshalToSizedBufferVT

func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Config) MarshalToVT

func (m *Config) MarshalToVT(dAtA []byte) (int, error)

func (*Config) MarshalVT

func (m *Config) MarshalVT() (dAtA []byte, err error)

func (*Config) ParsePeerID

func (c *Config) ParsePeerID() (peer.ID, error)

ParsePeerID parses the peer ID. may return nil.

func (*Config) ParseTargetPeerID

func (c *Config) ParseTargetPeerID() (peer.ID, error)

ParseTargetPeerID parses the target peer ID.

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) Reset

func (x *Config) Reset()

func (*Config) SizeVT

func (m *Config) SizeVT() (n int)

func (*Config) String

func (x *Config) String() string

func (*Config) UnmarshalJSON

func (x *Config) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the Config from JSON.

func (*Config) UnmarshalProtoJSON

func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the Config message from JSON.

func (*Config) UnmarshalVT

func (m *Config) UnmarshalVT(dAtA []byte) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration. This is a cursory validation to see if the values "look correct."

type Controller

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

Controller implements the relay controller. The controller handles HandleMountedStream directives by relaying the stream to a target peer ID.

func NewController

func NewController(
	le *logrus.Entry,
	bus bus.Bus,
	conf *Config,
) (*Controller, error)

NewController constructs a new relay controller.

func (*Controller) Close

func (c *Controller) Close() error

Close releases any resources used by the controller. Error indicates any issue encountered releasing.

func (*Controller) Execute

func (c *Controller) Execute(ctx context.Context) error

Execute executes the relay controller. Returning nil ends execution. Returning an error triggers a retry with backoff.

func (*Controller) GetControllerInfo

func (c *Controller) GetControllerInfo() *controller.Info

GetControllerInfo returns information about the controller.

func (*Controller) HandleDirective

func (c *Controller) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive. If it can, it returns a resolver. If not, returns nil. Any unexpected errors are returned for logging. It is safe to add a reference to the directive during this call.

type Factory

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

Factory constructs a relay controller

func NewFactory

func NewFactory(bus bus.Bus) *Factory

NewFactory builds a relay factory.

func (*Factory) Construct

func (t *Factory) Construct(
	ctx context.Context,
	conf config.Config,
	opts controller.ConstructOpts,
) (controller.Controller, error)

Construct constructs the associated controller given configuration.

func (*Factory) ConstructConfig

func (t *Factory) ConstructConfig() config.Config

ConstructConfig constructs an instance of the controller configuration.

func (*Factory) GetConfigID

func (t *Factory) GetConfigID() string

GetConfigID returns the configuration ID for the controller.

func (*Factory) GetControllerID

func (t *Factory) GetControllerID() string

GetControllerID returns the unique ID for the controller.

func (*Factory) GetVersion

func (t *Factory) GetVersion() semver.Version

GetVersion returns the version of this controller.

type MountedStreamHandler

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

MountedStreamHandler implements the mounted stream handler.

func NewMountedStreamHandler

func NewMountedStreamHandler(le *logrus.Entry, bus bus.Bus, targetPeerID peer.ID, targetProtocolID protocol.ID) (*MountedStreamHandler, error)

NewMountedStreamHandler constructs the mounted stream handler.

func (*MountedStreamHandler) HandleMountedStream

func (m *MountedStreamHandler) HandleMountedStream(
	ctx context.Context,
	strm link.MountedStream,
) error

HandleMountedStream handles an incoming mounted stream. Any returned error indicates the stream should be closed. This function should return as soon as possible, and start additional goroutines to manage the lifecycle of the stream.

type RelayResolver

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

RelayResolver resolves HandleMountedStream by relaying to a target peer.

func NewRelayResolver

func NewRelayResolver(le *logrus.Entry, bus bus.Bus, targetPeerID peer.ID, targetProtocolID protocol.ID) (*RelayResolver, error)

NewRelayResolver constructs a new relay resolver. targetProtocolID cannot be empty

func (*RelayResolver) Resolve

func (r *RelayResolver) Resolve(ctx context.Context, handler directive.ResolverHandler) error

Resolve resolves the values, emitting them to the handler.

Jump to

Keyboard shortcuts

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