xgrpc

package module
v0.0.0-...-04b1358 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2025 License: CC0-1.0 Imports: 11 Imported by: 10

README

xgrpc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call[REQ any, REPLY any, CT any, C Client[CT]](
	ctx context.Context,
	c C,
	fn func(context.Context, *REQ, ...grpc.CallOption) (REPLY, error),
	req *REQ,
	opts ...grpc.CallOption,
) (_ret REPLY, _err error)

func CallRetryable

func CallRetryable[REQ any, REPLY any, CT any, C ClientRetryable[CT]](
	ctx context.Context,
	c C,
	fn func(context.Context, *REQ, ...grpc.CallOption) (REPLY, error),
	req *REQ,
	opts ...grpc.CallOption,
) (REPLY, error)

func UnwrapChan

func UnwrapChan[E any, R any, S Receiver[R], CT any, C Client[CT]](
	ctx context.Context,
	c C,
	fn func(ctx context.Context, client CT) (S, error),
	parse func(ctx context.Context, event *R) E,
) (<-chan E, error)

func WrapChan

func WrapChan[T any, E any](
	ctx context.Context,
	getChan func(ctx context.Context) (<-chan E, error),
	sender Sender[T],
	parse func(E) *T,
) (_err error)

Types

type CallWrapperFunc

type CallWrapperFunc func(
	ctx context.Context,
	req any,
	callFunc func(ctx context.Context, opts ...grpc.CallOption) error,
	opts ...grpc.CallOption,
) error

type Client

type Client[CT any] interface {
	GRPCClient(context.Context) (CT, io.Closer, error)
	ProcessError(ctx context.Context, err error) error
	GetCallWrapper() CallWrapperFunc
}

type ClientRetryable

type ClientRetryable[CT any] interface {
	Client[CT]
	GetRetryConfig() RetryConfig
}

type Receiver

type Receiver[T any] interface {
	grpc.ClientStream

	Recv() (*T, error)
}

type RetryConfig

type RetryConfig struct {
	InitialInterval    time.Duration
	MaximalInterval    time.Duration
	IntervalMultiplier float64
}

type Sender

type Sender[T any] interface {
	grpc.ServerStream

	Send(*T) error
}

Jump to

Keyboard shortcuts

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