protocol

package
v0.0.0-...-81741d2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrClosed        = errors.New("closed")
	ErrUnimplemented = errors.New("unimplemented")
)
View Source
var DefaultDialFunc = func(network, addr string) (net.Conn, error) {
	conn, err := net.Dial(network, addr)
	if err != nil {
		return nil, errors.WithStack(err)
	}

	return conn, nil
}

Functions

func Register

func Register(identifier Identifier, factory ProtocolFactory)

Types

type BaseInfo

type BaseInfo struct {
	Mode          string
	AntennaOffset float64
	Latitude      float64
	Longitude     float64
	Height        float64
}

type DialFunc

type DialFunc func(network string, addr string) (net.Conn, error)

type Identifier

type Identifier string

type Operations

type Operations interface {
	// Connect initiates a new connection to the ReachView service
	// It should be called before any other operation
	Connect(ctx context.Context) error

	// Close closes the current connection to the ReachView service
	Close(ctx context.Context) error

	// Alive returns true if the ReachView websocket connection is alive, false otherwise
	Alive(ctx context.Context) (bool, error)

	// Version returns the current ReachView version,
	// true if the module uses the stable channel or an error
	Version(ctx context.Context) (string, bool, error)

	// On listens for messages of the given type on ReachView websocket connection
	On(ctx context.Context, mType string) (chan any, error)

	// Emit sends the given message on the ReachView websocket connection
	Emit(ctx context.Context, mType string, message any) error

	// Configuration retrieves the module's configuration
	Configuration(ctx context.Context) (any, error)

	// SetBase updates the base configuration
	SetBase(ctx context.Context, funcs ...SetBaseOptionFunc) error

	GetBaseInfo(ctx context.Context) (*BaseInfo, error)

	// Reboot restarts the module
	Reboot(ctx context.Context) error
}

type Protocol

type Protocol interface {
	Identifier() Identifier
	Available(ctx context.Context, addr string) (bool, error)
	Operations(addr string) Operations
}

func Availables

func Availables(ctx context.Context, addr string, timeout time.Duration) ([]Protocol, error)

type ProtocolFactory

type ProtocolFactory func(opts *ProtocolOptions) (Protocol, error)

type ProtocolOptionFunc

type ProtocolOptionFunc func(opts *ProtocolOptions)

func WithProtocolDial

func WithProtocolDial(dial DialFunc) ProtocolOptionFunc

func WithProtocolLogger

func WithProtocolLogger(logger logger.Logger) ProtocolOptionFunc

type ProtocolOptions

type ProtocolOptions struct {
	Logger logger.Logger
	Dial   DialFunc
}

func NewProtocolOptions

func NewProtocolOptions(funcs ...ProtocolOptionFunc) *ProtocolOptions

type Registry

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

func DefaultRegistry

func DefaultRegistry() *Registry

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Availables

func (r *Registry) Availables(ctx context.Context, addr string, timeout time.Duration, funcs ...ProtocolOptionFunc) ([]Protocol, error)

func (*Registry) Get

func (r *Registry) Get(identifier Identifier, funcs ...ProtocolOptionFunc) (Protocol, error)

func (*Registry) Register

func (r *Registry) Register(identifier Identifier, factory ProtocolFactory)

type SetBaseOptionFunc

type SetBaseOptionFunc func(opts *SetBaseOptions)

func WithBaseAntennaOffset

func WithBaseAntennaOffset(value float64) SetBaseOptionFunc

func WithBaseHeight

func WithBaseHeight(value float64) SetBaseOptionFunc

func WithBaseLatitude

func WithBaseLatitude(value float64) SetBaseOptionFunc

func WithBaseLongitude

func WithBaseLongitude(value float64) SetBaseOptionFunc

func WithBaseMode

func WithBaseMode(value string) SetBaseOptionFunc

type SetBaseOptions

type SetBaseOptions struct {
	Mode          *string
	AntennaOffset *float64
	Latitude      *float64
	Longitude     *float64
	Height        *float64
}

func NewSetBaseOptions

func NewSetBaseOptions(funcs ...SetBaseOptionFunc) *SetBaseOptions

Directories

Path Synopsis
v1
v2

Jump to

Keyboard shortcuts

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