client

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package client provides discovery service client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GRPCDialOptions added in v0.1.9

func GRPCDialOptions(options Options) []grpc.DialOption

GRPCDialOptions returns gRPC dial options for the given client options.

Types

type Affiliate

type Affiliate struct {
	Affiliate *clientpb.Affiliate
	Endpoints []*clientpb.Endpoint
}

Affiliate information.

type Client

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

Client wraps all details related to discovery service interaction.

Inputs for the client are: * Affiliate protobuf structure (for the node itself) * Additional endpoints discovered for other nodes (affiliates)

Outputs are: * list of Affiliates (except for the node itself) * channel which notifies when list of Affiliates changes

Client handles encryption of the data.

func NewClient

func NewClient(options Options) (*Client, error)

NewClient initializes a client.

func (*Client) DeleteLocalAffiliate

func (client *Client) DeleteLocalAffiliate()

DeleteLocalAffiliate marks local affiliate for deletion.

Actual deletion happens on the next update in the Run loop.

func (*Client) GetAffiliates

func (client *Client) GetAffiliates() []*Affiliate

GetAffiliates returns discovered affiliates.

func (*Client) GetPublicIP added in v0.1.3

func (client *Client) GetPublicIP() []byte

GetPublicIP returns client's discovered public IP.

func (*Client) Run

func (client *Client) Run(ctx context.Context, logger *zap.Logger, notifyCh chan<- struct{}) error

Run the client loop.

Client automatically keeps the connection, refreshes data based on TTL. Run loop shuts down when context is canceled.

func (*Client) SetLocalData

func (client *Client) SetLocalData(localAffiliate *Affiliate, otherEndpoints []Endpoint) error

SetLocalData updates local affiliate data.

type Endpoint

type Endpoint struct {
	AffiliateID string
	Endpoints   []*clientpb.Endpoint
}

Endpoint specified additional endpoints for other affiliates.

type Options

type Options struct {
	// Cipher, should have 32-bytes (128-bit key).
	Cipher cipher.Block
	// gRPC initial endpoint.
	Endpoint string
	// ClusterID of the client.
	ClusterID string
	// AffiliateID of the client.
	AffiliateID string
	// ClientVersion for the Hello request.
	ClientVersion string
	// TTL for the submitted data.
	TTL time.Duration
	// Insecure gRPC connection (only for testing)
	Insecure bool
}

Options configures the client.

Jump to

Keyboard shortcuts

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