connections

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPGetWithClient

func HTTPGetWithClient[T protoreflect.ProtoMessage](ctx context.Context, url string, client *http.Client, val T, authHeader string) error

func HTTPPostWithClient

func HTTPPostWithClient[T protoreflect.ProtoMessage](ctx context.Context, url string, client *http.Client, body interface{}, val T, authHeader string) error

Types

type FeedUpdate

type FeedUpdate struct {
	SubscriptionID string          `json:"subscription"`
	Result         json.RawMessage `json:"result"`
}

FeedUpdate wraps the result from any particular stream with the subscription ID it's associated with

type HTTPError

type HTTPError struct {
	Code    int         `json:"code"`
	Details interface{} `json:"details"`
	Message string      `json:"message"`
}

func (HTTPError) Error

func (h HTTPError) Error() string

type Streamer

type Streamer[T any] func() (T, error)

func GRPCStream

func GRPCStream[T any](stream grpc.ClientStream, input string) Streamer[*T]

func WSStreamAny added in v1.5.0

func WSStreamAny[T any](w *WS, ctx context.Context, streamName string, streamParams interface{}) (Streamer[T], error)

func WSStreamProto added in v1.5.0

func WSStreamProto[T proto.Message](w *WS, ctx context.Context, streamName string, streamParams proto.Message, resultInitFn func() T) (Streamer[T], error)

func (Streamer[T]) Channel

func (s Streamer[T]) Channel(size int) chan T

func (Streamer[T]) Into

func (s Streamer[T]) Into(ch chan T)

type SubscribeParams

type SubscribeParams struct {
	StreamName string
	StreamOpts json.RawMessage
}

SubscribeParams exist because subscribe arguments usually look like ["streamName", {"some": "opts"}], which doesn't map elegantly to Go structs

func (SubscribeParams) MarshalJSON

func (s SubscribeParams) MarshalJSON() ([]byte, error)

func (*SubscribeParams) UnmarshalJSON

func (s *SubscribeParams) UnmarshalJSON(b []byte) error

type UnsubscribeParams

type UnsubscribeParams struct {
	SubscriptionID string
}

UnsubscribeParams exist because unsubscribe arguments usually look like ["subscriptionID"], which doesn't map elegantly to Go structs

func (UnsubscribeParams) MarshalJSON

func (s UnsubscribeParams) MarshalJSON() ([]byte, error)

func (*UnsubscribeParams) UnmarshalJSON

func (s *UnsubscribeParams) UnmarshalJSON(b []byte) error

type WS

type WS struct {

	// public to allow overriding of (un)subscribe method name
	SubscribeMethodName   string
	UnsubscribeMethodName string
	// contains filtered or unexported fields
}

func NewWS

func NewWS(endpoint string, authHeader string) (*WS, error)

func (*WS) Close

func (w *WS) Close(reason error) error

func (*WS) Request

func (w *WS) Request(ctx context.Context, method string, request proto.Message, response proto.Message) error

Jump to

Keyboard shortcuts

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