internal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IfNotNil

func IfNotNil[From any, To any](value *From, mapper func(*From) To) To

IfNotNil apply the mapper func if the value is not nil returns zero value otherwise.

func IfNotNilP

func IfNotNilP[From any, To any](value *From, mapper func(*From) To) *To

IfNotNilP apply the mapper func if the value is not nil returns nil otherwise.

func Map

func Map[From any, To any](from []From, mapper func(From) To) []To

Map apply the given function to all list elements.

func MapValuesErr

func MapValuesErr[From any, To any](from map[string]From, mapper func(From) (To, error)) (map[string]To, error)

MapValues transform map values by applying mapper func.

func ZeroValueIfNil

func ZeroValueIfNil[T any](v *T) T

ZeroValueIfNil returns the zero value if the variable is nil.

Types

type AcknowledgementManager

type AcknowledgementManager[TAckResult any] struct {
	// contains filtered or unexported fields
}

AcknowledgementManager control the messages acknowledgement from the server.

func NewAckManager

func NewAckManager[TAckResult any]() *AcknowledgementManager[TAckResult]

func (*AcknowledgementManager[TAckResult]) Ack

func (m *AcknowledgementManager[TAckResult]) Ack(messageID string, result TAckResult) error

Ack acknowledge a message

func (*AcknowledgementManager[TAckResult]) Get

func (m *AcknowledgementManager[TAckResult]) Get() (messageID string, ackChan chan TAckResult, cleanup func())

Get generate a new messageID for Get acks and returns the ack chan.

func (*AcknowledgementManager[TAckResult]) Pending

func (m *AcknowledgementManager[TAckResult]) Pending() []chan TAckResult

Pending returns a copy of pending acks list

type GRPCServerStream

type GRPCServerStream[TSend any, TRecv any] interface {
	Send(*TSend) error
	Recv() (*TRecv, error)
}

GRPCServerStream is the interface for server streaming.

type GRPCThreadSafeStream

type GRPCThreadSafeStream[TSend any, TRecv any, TStream GRPCServerStream[TSend, TRecv]] struct {
	// contains filtered or unexported fields
}

GRPCThreadSafeStream wraps a grpcStream for thread safe operations. As per documentation is unsafe to call recv OR send in multiples goroutines https://github.com/grpc/grpc-go/blob/master/Documentation/concurrency.md#streams it is safe to call recv AND send in different goroutines.

func (*GRPCThreadSafeStream[TSend, TRecv, GRPCServerStream]) Recv

func (s *GRPCThreadSafeStream[TSend, TRecv, GRPCServerStream]) Recv() (*TRecv, error)

func (*GRPCThreadSafeStream[TSend, TRecv, GRPCServerStream]) Send

func (s *GRPCThreadSafeStream[TSend, TRecv, GRPCServerStream]) Send(msg *TSend) error

type ThreadSafeStream

type ThreadSafeStream[TSend any, TRecv any] interface {
	GRPCServerStream[TSend, TRecv]
}

ThreadSafeStream wraps a grpc stream with locks to permit send and recv in multiples goroutines.

func NewGRPCThreadSafeStream

func NewGRPCThreadSafeStream[TSend any, TRecv any](stream GRPCServerStream[TSend, TRecv]) ThreadSafeStream[TSend, TRecv]

Jump to

Keyboard shortcuts

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