client

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	SendEvent(eid event.Id, in interface{})
	ConnectID() string
	Header(key, value string)
	SetHandler(call Handler, eids ...event.Id)
	DelHandler(eids ...event.Id)
	OnClose(cb func(cid string))
	OnOpen(cb func(cid string))
	Close()
	DialAndListen() error
}

func New

func New(ctx context.Context, url string, l xlog.Logger, opts ...func(Option)) Client

type Handler

type Handler func(w Request, r Response, m Meta)

type ListenArg

type ListenArg interface {
	Decode(in interface{}) error
}

type Meta

type Meta interface {
	ConnectID() string
}

type Observable

type Observable interface {
	Subscribe(eid event.Id, in interface{}) Subscription
}

func NewObservable

func NewObservable(cli ObservableClient) Observable

type ObservableClient

type ObservableClient interface {
	OnClose(cb func(cid string))
	SendEvent(eid event.Id, in interface{})
	DelHandler(eids ...event.Id)
	SetHandler(call Handler, eids ...event.Id)
}

type Option

type Option interface {
	Header(key, value string)
}

type PipeFunc

type PipeFunc func(ctx context.Context) context.Context

func PipeTake

func PipeTake(count uint64) PipeFunc

func PipeTimeout

func PipeTimeout(t time.Duration) PipeFunc

type Request

type Request interface {
	Encode(in interface{})
	EncodeEvent(id event.Id, in interface{})
}

type Response

type Response interface {
	EventID() event.Id
	Decode(in interface{}) error
}

type Subscription

type Subscription interface {
	Listen(call func(ListenArg), pipe ...PipeFunc)
	Unsubscribe()
}

Jump to

Keyboard shortcuts

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