share

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

share cluster nodes info

Index

Constants

View Source
const (
	PROTOCOL_V1 = "/cluster/share/0.0.1"
)

Variables

This section is empty.

Functions

func ReadReply

func ReadReply(s network.Stream, msg *ShareReply) error

func ReadRequest

func ReadRequest(s network.Stream, msg *ShareRequest) error

func WriteReply

func WriteReply(s network.Stream, msg *ShareReply) error

func WriteRequst

func WriteRequst(s network.Stream, msg *ShareRequest) error

Types

type Client

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

func NewShareClient

func NewShareClient(ctx context.Context, src host.Host, target peer.AddrInfo) *Client

func (*Client) Close

func (cl *Client) Close() error

func (*Client) ConnectTarget

func (cl *Client) ConnectTarget() error

func (*Client) GetClusterInfo

func (cl *Client) GetClusterInfo() (value []byte, err error)

func (*Client) GetIdentity

func (cl *Client) GetIdentity(idx int) (value []byte, err error)

func (*Client) IsTargetConnected

func (cl *Client) IsTargetConnected() bool

type ErrCode

type ErrCode uint8
const (
	ErrNone ErrCode = iota
	ErrNotFound

	ErrOthers = 100
)

type InfoType

type InfoType uint8
const (
	InfoClusterNodes InfoType = 1 + iota
	InfoIdentity
)

type Server

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

func NewShareServer

func NewShareServer(ctx context.Context, h host.Host, cfg *config.Config) *Server

func (*Server) Close

func (sv *Server) Close() error

func (*Server) Serve

func (sv *Server) Serve()

type ShareReply

type ShareReply struct {
	Code ErrCode
	Msg  string
	Type InfoType
	Info []byte
}

func (*ShareReply) MarshalCBOR

func (t *ShareReply) MarshalCBOR(w io.Writer) error

func (*ShareReply) UnmarshalCBOR

func (t *ShareReply) UnmarshalCBOR(r io.Reader) error

type ShareRequest

type ShareRequest struct {
	Type  InfoType
	Index int64
}

func (*ShareRequest) MarshalCBOR

func (t *ShareRequest) MarshalCBOR(w io.Writer) error

func (*ShareRequest) UnmarshalCBOR

func (t *ShareRequest) UnmarshalCBOR(r io.Reader) error

Jump to

Keyboard shortcuts

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