stream

package module
v0.0.0-...-d9ac5fd Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 3 Imported by: 1

README

stream

Client-side stream manager for isglb and sxu.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client[RequestType, ResponseType any] struct {
	ClientStreamFactory[RequestType, ResponseType]
	// contains filtered or unexported fields
}

func NewClient

func NewClient[RequestType, ResponseType any](factory ClientStreamFactory[RequestType, ResponseType]) *Client[RequestType, ResponseType]

func (*Client[RequestType, ResponseType]) Close

func (c *Client[RequestType, ResponseType]) Close()

func (*Client[RequestType, ResponseType]) Connect

func (c *Client[RequestType, ResponseType]) Connect()

func (*Client[RequestType, ResponseType]) Connected

func (c *Client[RequestType, ResponseType]) Connected() bool

func (*Client[RequestType, ResponseType]) DoWithClient

func (c *Client[RequestType, ResponseType]) DoWithClient(op func(client ClientStream[RequestType, ResponseType]) error) bool

DoWithClient do something with c.stream

func (*Client[RequestType, ResponseType]) OnMsgRecv

func (c *Client[RequestType, ResponseType]) OnMsgRecv(f func(ResponseType))

func (*Client[RequestType, ResponseType]) OnReconnect

func (c *Client[RequestType, ResponseType]) OnReconnect(f func())

func (*Client[RequestType, ResponseType]) Reconnect

func (c *Client[RequestType, ResponseType]) Reconnect()

func (*Client[RequestType, ResponseType]) ReconnectNotVerify

func (c *Client[RequestType, ResponseType]) ReconnectNotVerify()

func (*Client[RequestType, ResponseType]) Send

func (c *Client[RequestType, ResponseType]) Send(request RequestType)

Send send the request, maybe lose when cannot connect

type ClientStream

type ClientStream[RequestType, ResponseType any] interface {
	Send(RequestType) error
	Recv() (ResponseType, error)
}

type ClientStreamFactory

type ClientStreamFactory[RequestType, ResponseType any] interface {
	NewClientStream(ctx context.Context) (ClientStream[RequestType, ResponseType], error)
}

Jump to

Keyboard shortcuts

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