client

package
v0.0.0-...-39055d0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Overview

Copyright (c) 2021-2023 - for information on the respective copyright owner see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is used to communicate with Discovery service. It is a wrapper around the gRPC client. To send events one writes to the Out channel, reading is done by consuming messages from the In channel. Errors are forwarded to the errCh specified in the config. Thus it must be monitored.

func NewClient

func NewClient(conf *TransportClientConfig) (*Client, error)

NewClient returns a new transport client.

func (*Client) Connect

func (c *Client) Connect() (*grpc.ClientConn, error)

Connect dials the server and returns a connection.

func (*Client) GetIn

func (c *Client) GetIn() chan *pb.Event

GetIn returns In channel of the client.

func (*Client) GetOut

func (c *Client) GetOut() chan *pb.Event

GetOut returns Out channel of the client.

func (*Client) Run

func (c *Client) Run(client pb.DiscoveryClient)

Run starts forwarding of the events. The functionality is started as separate go routines which run until the given context is closed, or a communication error occurs.

func (*Client) Stop

func (c *Client) Stop() error

Stop closes the underlying gRPC stream and its TCP connection.

type TransportClient

type TransportClient interface {
	GetIn() chan *pb.Event
	GetOut() chan *pb.Event
	Connect() (*grpc.ClientConn, error)
	Run(client pb.DiscoveryClient)
	Stop() error
}

TransportClient is an interface for the underlying transport connection, e.g. GRPC.

type TransportClientConfig

type TransportClientConfig struct {
	// In, Out is the external interface for the libraries that would like to use this client. Events received from "In" are forwarded to the server. The responses are sent back to "Out"
	In, Out chan *pb.Event

	// ErrCh is the sink for all errors from the client. It is supposed to be a buffered channel with a minimum capacity of `1`.
	ErrCh chan error

	// Host, Port - the server endpoint to connect to.
	Host, Port string

	// EventScope defines the scope of events the client subscribes to. "all" - events from all games are current games, "ConnID" - events associated with this connection ID.
	EventScope string

	// ConnID is the ID of the connection. In case of pure discovery clients, it is equal the gameID.
	ConnID string

	// ConnectTimeout is the gRPC dial timeout.
	ConnectTimeout time.Duration

	Logger *zap.SugaredLogger

	Context context.Context
}

TransportClientConfig preserves config params of the client.

type TransportConn

type TransportConn interface {
	Close() error
}

TransportConn is an interface for the underlying gRPC transport connection.

Jump to

Keyboard shortcuts

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