connection

package
v0.0.0-...-c01ea1d Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseError

type CloseError struct {
	ConnectionID ID
	Errors       []error
}

func (*CloseError) Error

func (e *CloseError) Error() string

type CloseRequest

type CloseRequest struct {
	ConnectionID ID
}

type ConnectRejectError

type ConnectRejectError struct {
	ConnectionID ID
	Reasons      []string
}

func (*ConnectRejectError) Error

func (e *ConnectRejectError) Error() string

type ConnectRequest

type ConnectRequest struct {
	ConnectionID ID
	Sender       peer.ID
	Receiver     peer.ID
	Options      Options
}

type ConnectResponse

type ConnectResponse struct {
	ConnectionID ID
	// Errors represent any errors that may have occurred during processing of the request
	// that the receiver would like to make the sender aware of.
	// This is distinct from the decision to not accept the connection for whatever business
	// logic reasons, which should be signaled using the Accept flag and RejectReasons.
	//
	// If Errors is both non-nil and non-empty, then the values of Accept and RejectReasons
	// are ignored.
	//
	// The underlying transport may use this to notify the sender of errors or may use some
	// other method to inform the sender-side transport layer that it should signal an error.
	Errors        []string
	Accepted      bool
	RejectReasons []string
}

type Connection

type Connection interface {
	ID() ID
	Sender() peer.ID
	Witness() peer.ID
	// SetWitness returns a connection that is identical to the receiver with the addition of having the witness value be the specified peerID.
	//
	// This operation return a Connection to allow immutable implementations, but implementations may also allow mutation. However, if an
	// implementation allows mutation, it must return the receiver. When using this method, it is best practice to discard the receiver
	// and only refer to the returned value from that point forward.
	SetWitness(peerID peer.ID) (Connection, error)
	Receiver() peer.ID
	Status() Status
	// SetStatus returns a connection that is identical to the receiver with the addition of having the status now equaling the supplied argument.
	//
	// This operation return a Connection to allow immutable implementations, but implementations may also allow mutation. However, if an
	// implementation allows mutation, it must return the receiver. When using this method, it is best practice to discard the receiver
	// and only refer to the returned value from that point forward.
	SetStatus(status Status) (Connection, error)
}

type ConnectionStore

type ConnectionStore interface {
	// Update allows modification of the connection specified by the provided id.
	//
	// The connection returned from writeFunc is used to persist any changes. This applies
	// even if writeFunc also returns an error. Return a nil connection to signal that no
	// persistence should occur.
	//
	// This funcction only calls writeFunc if the connection exists. If no connection is found,
	// this operation returns an error.
	Update(id ID, writeFunc func(conn Connection) (Connection, error)) error
	// Read allows concurrent access to a connection but does not allow modification.
	//
	// This function does not ensure that the connection exists and calls readFunc regardless.
	// As such any nil checking must be performed in readFunc.
	Read(id ID, readFunc func(conn Connection) error) error
	Create(sender, receiver peer.Peer, status Status) (ID, error)
	Accept(id ID, sender, receiver peer.Peer, status Status) error
	All() ([]ID, error)
}

ConnetionStore is an interface for some backing storage for the Clarinet connections a node has. All operations on types implementing this interface must provide concurrency safety.

type ID

type ID uuid.UUID

func NewRandomID

func NewRandomID() (ID, error)

func (ID) String

func (id ID) String() string

type Options

type Options struct {
	WitnessSelector WitnessSelector
}

type Status

type Status interface {
	String() string
	// contains filtered or unexported methods
}

func AwaitingWitness

func AwaitingWitness() Status

func Closed

func Closed() Status

func Closing

func Closing() Status

func NotifyingOfWitness

func NotifyingOfWitness() Status

func Open

func Open() Status

func RequestingReceiver

func RequestingReceiver() Status

func RequestingSender

func RequestingSender() Status

func RequestingWitness

func RequestingWitness() Status

type WitnessNotification

type WitnessNotification struct {
	ConnectionID ID
	Witness      peer.ID
}

type WitnessRejectError

type WitnessRejectError struct {
	ConnectionID ID
	Reasons      []string
}

func (*WitnessRejectError) Error

func (e *WitnessRejectError) Error() string

type WitnessRequest

type WitnessRequest struct {
	ConnectionID ID
	Sender       peer.ID
	Receiver     peer.ID
	Options      Options
}

type WitnessResponse

type WitnessResponse struct {
	ConnectionID ID
	// Errors represent any errors that may have occurred during processing of the request
	// that the receiver would like to make the sender aware of.
	// This is distinct from the decision to not accept the connection for whatever business
	// logic reasons, which should be signaled using the Accept flag and RejectReasons.
	//
	// If Errors is both non-nil and non-empty, then the values of Accept and RejectReasons
	// are ignored.
	//
	// The underlying transport may use this to notify the sender of errors or may use some
	// other method to inform the sender-side transport layer that it should signal an error.
	Errors        []string
	Accepted      bool
	RejectReasons []string
}

type WitnessSelector

type WitnessSelector interface {
	String() string
	// contains filtered or unexported methods
}

func ParseWitnessSelector

func ParseWitnessSelector(s string) (WitnessSelector, error)

func WitnessSelectorReceiver

func WitnessSelectorReceiver() WitnessSelector

func WitnessSelectorSender

func WitnessSelectorSender() WitnessSelector

Jump to

Keyboard shortcuts

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