grpcpubsub

package
v4.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const Scheme = "grpc"

Scheme is the URL scheme grpc pubsub registers its URLOpeners under on pubsub.DefaultMux.

Variables

This section is empty.

Functions

func NewSubscription

func NewSubscription(path string, opts ...Option) (*pubsub.Subscription, error)

NewSubscription returns a *pubsub.Subscription representing a NATS subscription or NATS queue subscription. The subject is the NATS Subject to subscribe to; for more info, see https://nats.io/documentation/writing_applications/subjects.

func NewTopic

func NewTopic(path, pubKey string, opts ...Option) (*pubsub.Topic, error)

NewTopic creates a new in-memory topic.

Types

type Option

type Option func(*Options)

func WithContext

func WithContext(ctx context.Context) Option

func WithPublisher

func WithPublisher(pub Publisher) Option

WithPublisher sets the RPC client

func WithQueue

func WithQueue(s string) Option

WithQueue defines the queue used by the subscriber

func WithSubscriber

func WithSubscriber(sub interface{}) Option

WithSubscriber sets the client

type Options

type Options struct {
	Context context.Context
	Queue   string
}

type Publisher

type Publisher interface {
	Send(*pb.PublishRequest) error
}

type Subscriber

type Subscriber interface {
	Recv() (*pb.SubscribeResponse, error)
}

type URLOpener

type URLOpener struct {
	// contains filtered or unexported fields
}

URLOpener opens grpc pubsub URLs like "cells://topic".

The URL's host+path is used as the topic to create or subscribe to.

Query parameters:

  • ackdeadline: The ack deadline for OpenSubscription, in time.ParseDuration formats. Defaults to 1m.

func (*URLOpener) OpenSubscriptionURL

func (o *URLOpener) OpenSubscriptionURL(ctx context.Context, u *url.URL) (*pubsub.Subscription, error)

OpenSubscriptionURL opens a pubsub.Subscription based on u.

func (*URLOpener) OpenTopicURL

func (o *URLOpener) OpenTopicURL(ctx context.Context, u *url.URL) (*pubsub.Topic, error)

OpenTopicURL opens a pubsub.Topic based on u.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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