service

package
v0.0.0-...-64c530f Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0, BSD-2-Clause Imports: 6 Imported by: 16

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint interface {
	Network() string
	Port() int
}

Endpoint defines where a service can be reached.

type Key

type Key string

Key is the type of keys used to look-up a service.

const (
	// PeeringKey is the key for the auto peering service.
	PeeringKey Key = "peering"
	// FPCKey is the key for the FPC service.
	FPCKey Key = "fpc"
	// P2PKey is the key for the p2p service.
	P2PKey Key = "p2p"
)

type Record

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

Record defines the mapping between a service ID and its tuple TypePort e.g., map[autopeering:&{TCP, 8000}].

func FromProto

func FromProto(in *pb.ServiceMap) (*Record, error)

FromProto creates a Record from the provided protobuf struct.

func New

func New() *Record

New initializes and returns an empty new Record.

func Unmarshal

func Unmarshal(data []byte) (*Record, error)

Unmarshal de-serializes a given slice of bytes (data) into a Peer.

func (*Record) CreateRecord

func (s *Record) CreateRecord() *Record

CreateRecord creates a modifyable Record from the services.

func (*Record) Get

func (s *Record) Get(key Key) Endpoint

Get returns the network end point address of the service with the given name.

func (*Record) Marshal

func (s *Record) Marshal() ([]byte, error)

Marshal serializes a given Peer (p) into a slice of bytes.

func (*Record) MarshalJSON

func (s *Record) MarshalJSON() ([]byte, error)

MarshalJSON serializes Record struct into JSON data.

func (*Record) String

func (s *Record) String() string

String returns a string representation of the service record.

func (*Record) ToProto

func (s *Record) ToProto() *pb.ServiceMap

ToProto returns the corresponding protobuf struct.

func (*Record) UnmarshalJSON

func (s *Record) UnmarshalJSON(b []byte) error

UnmarshalJSON deserializes JSON data into Record struct.

func (*Record) Update

func (s *Record) Update(key Key, network string, port int)

Update adds a new service to the map.

type Service

type Service interface {
	// Get returns the network end point address of the given service or nil if not supported.
	Get(Key) Endpoint

	// CreateRecord creates a modifyable Record from the services.
	CreateRecord() *Record
}

Service is a read-only interface to access services.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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