grpc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 13 Imported by: 3

README

gRPC Wrapper for Pub/Sub Brokers

This provides an interface for interacting with a pub/sub server via gRPC. This is useful if you want to hide the underlying broker implementation.

Documentation

Overview

Package grpc is a generated protocol buffer package.

It is generated from these files:

grpc/server.proto

It has these top-level messages:

PublishRequest
PublishResponse
SubscribeRequest
SubscribeResponse
AckRequest
AckResponse
DeleteTopicRequest
DeleteTopicResponse
DeleteSubscriptionRequest
DeleteSubscriptionResponse

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPublisher

func NewPublisher(topic string, conn *grpc.ClientConn) pubsub.Publisher

NewPublisher returns an implementation of pubsub.Publisher from the given grpc connection. This is a convenience in case you want to operate with go channels instead of interacting with the client directly

func NewSubscriber

func NewSubscriber(topic, subscriptionID string, conn *grpc.ClientConn) pubsub.Subscriber

NewSubscriber returns an implementation of pubsub.Subscriber from the given grpc connection. This is a convenience in case you want to operate with go channels instead of interacting with the client directly

func RegisterPubSubServer

func RegisterPubSubServer(s *grpc1.Server, srv PubSubServer)

Types

type AckRequest

type AckRequest struct {
	Topic          string `protobuf:"bytes,1,opt,name=topic" json:"topic,omitempty"`
	SubscriptionId string `protobuf:"bytes,2,opt,name=subscription_id,json=subscriptionId" json:"subscription_id,omitempty"`
	MessageId      string `protobuf:"bytes,3,opt,name=message_id,json=messageId" json:"message_id,omitempty"`
}

func (*AckRequest) Descriptor

func (*AckRequest) Descriptor() ([]byte, []int)

func (*AckRequest) GetMessageId

func (m *AckRequest) GetMessageId() string

func (*AckRequest) GetSubscriptionId

func (m *AckRequest) GetSubscriptionId() string

func (*AckRequest) GetTopic

func (m *AckRequest) GetTopic() string

func (*AckRequest) ProtoMessage

func (*AckRequest) ProtoMessage()

func (*AckRequest) Reset

func (m *AckRequest) Reset()

func (*AckRequest) String

func (m *AckRequest) String() string

type AckResponse

type AckResponse struct {
}

func (*AckResponse) Descriptor

func (*AckResponse) Descriptor() ([]byte, []int)

func (*AckResponse) ProtoMessage

func (*AckResponse) ProtoMessage()

func (*AckResponse) Reset

func (m *AckResponse) Reset()

func (*AckResponse) String

func (m *AckResponse) String() string

type DeleteSubscriptionRequest added in v0.3.0

type DeleteSubscriptionRequest struct {
	Topic          string `protobuf:"bytes,1,opt,name=topic" json:"topic,omitempty"`
	SubscriptionId string `protobuf:"bytes,2,opt,name=subscription_id,json=subscriptionId" json:"subscription_id,omitempty"`
}

func (*DeleteSubscriptionRequest) Descriptor added in v0.3.0

func (*DeleteSubscriptionRequest) Descriptor() ([]byte, []int)

func (*DeleteSubscriptionRequest) GetSubscriptionId added in v0.3.0

func (m *DeleteSubscriptionRequest) GetSubscriptionId() string

func (*DeleteSubscriptionRequest) GetTopic added in v0.3.0

func (m *DeleteSubscriptionRequest) GetTopic() string

func (*DeleteSubscriptionRequest) ProtoMessage added in v0.3.0

func (*DeleteSubscriptionRequest) ProtoMessage()

func (*DeleteSubscriptionRequest) Reset added in v0.3.0

func (m *DeleteSubscriptionRequest) Reset()

func (*DeleteSubscriptionRequest) String added in v0.3.0

func (m *DeleteSubscriptionRequest) String() string

type DeleteSubscriptionResponse added in v0.3.0

type DeleteSubscriptionResponse struct {
}

func (*DeleteSubscriptionResponse) Descriptor added in v0.3.0

func (*DeleteSubscriptionResponse) Descriptor() ([]byte, []int)

func (*DeleteSubscriptionResponse) ProtoMessage added in v0.3.0

func (*DeleteSubscriptionResponse) ProtoMessage()

func (*DeleteSubscriptionResponse) Reset added in v0.3.0

func (m *DeleteSubscriptionResponse) Reset()

func (*DeleteSubscriptionResponse) String added in v0.3.0

func (m *DeleteSubscriptionResponse) String() string

type DeleteTopicRequest added in v0.3.0

type DeleteTopicRequest struct {
	Topic string `protobuf:"bytes,1,opt,name=topic" json:"topic,omitempty"`
}

func (*DeleteTopicRequest) Descriptor added in v0.3.0

func (*DeleteTopicRequest) Descriptor() ([]byte, []int)

func (*DeleteTopicRequest) GetTopic added in v0.3.0

func (m *DeleteTopicRequest) GetTopic() string

func (*DeleteTopicRequest) ProtoMessage added in v0.3.0

func (*DeleteTopicRequest) ProtoMessage()

func (*DeleteTopicRequest) Reset added in v0.3.0

func (m *DeleteTopicRequest) Reset()

func (*DeleteTopicRequest) String added in v0.3.0

func (m *DeleteTopicRequest) String() string

type DeleteTopicResponse added in v0.3.0

type DeleteTopicResponse struct {
}

func (*DeleteTopicResponse) Descriptor added in v0.3.0

func (*DeleteTopicResponse) Descriptor() ([]byte, []int)

func (*DeleteTopicResponse) ProtoMessage added in v0.3.0

func (*DeleteTopicResponse) ProtoMessage()

func (*DeleteTopicResponse) Reset added in v0.3.0

func (m *DeleteTopicResponse) Reset()

func (*DeleteTopicResponse) String added in v0.3.0

func (m *DeleteTopicResponse) String() string

type ErrorHandler

type ErrorHandler func(error)

ErrorHandler allows handling any errors that come during subscription, like logging it or terminating early

type PubSubClient

type PubSubClient interface {
	Publish(ctx context.Context, in *PublishRequest, opts ...grpc1.CallOption) (*PublishResponse, error)
	DeleteTopic(ctx context.Context, in *DeleteTopicRequest, opts ...grpc1.CallOption) (*DeleteTopicResponse, error)
	Subscribe(ctx context.Context, in *SubscribeRequest, opts ...grpc1.CallOption) (PubSub_SubscribeClient, error)
	DeleteSubscription(ctx context.Context, in *DeleteSubscriptionRequest, opts ...grpc1.CallOption) (*DeleteSubscriptionResponse, error)
	Ack(ctx context.Context, in *AckRequest, opts ...grpc1.CallOption) (*AckResponse, error)
}

func NewPubSubClient

func NewPubSubClient(cc *grpc1.ClientConn) PubSubClient

type PubSubServer

func NewPubSubServer

func NewPubSubServer(publisherFactory PublisherFactory, subscriberFactory SubscriberFactory, opts ...PubSubServerOption) PubSubServer

NewPubSubServer returns an implementation of PubSubServer by consuming a pubsub.Publisher and pubsub.OnceSubscriber implementation

type PubSubServerOption added in v0.4.0

type PubSubServerOption func(*grpcWrapper)

func WithLogger added in v0.4.0

func WithLogger(logger *logrus.Logger) PubSubServerOption

type PubSub_SubscribeClient

type PubSub_SubscribeClient interface {
	Recv() (*SubscribeResponse, error)
	grpc1.ClientStream
}

type PubSub_SubscribeServer

type PubSub_SubscribeServer interface {
	Send(*SubscribeResponse) error
	grpc1.ServerStream
}

type PublishRequest

type PublishRequest struct {
	Topic    string            `protobuf:"bytes,1,opt,name=topic" json:"topic,omitempty"`
	Message  []byte            `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Metadata map[string]string `` /* 136-byte string literal not displayed */
}

func (*PublishRequest) Descriptor

func (*PublishRequest) Descriptor() ([]byte, []int)

func (*PublishRequest) GetMessage

func (m *PublishRequest) GetMessage() []byte

func (*PublishRequest) GetMetadata

func (m *PublishRequest) GetMetadata() map[string]string

func (*PublishRequest) GetTopic

func (m *PublishRequest) GetTopic() string

func (*PublishRequest) ProtoMessage

func (*PublishRequest) ProtoMessage()

func (*PublishRequest) Reset

func (m *PublishRequest) Reset()

func (*PublishRequest) String

func (m *PublishRequest) String() string

type PublishResponse

type PublishResponse struct {
}

func (*PublishResponse) Descriptor

func (*PublishResponse) Descriptor() ([]byte, []int)

func (*PublishResponse) ProtoMessage

func (*PublishResponse) ProtoMessage()

func (*PublishResponse) Reset

func (m *PublishResponse) Reset()

func (*PublishResponse) String

func (m *PublishResponse) String() string

type PublisherFactory

type PublisherFactory func(context.Context, string) (pubsub.Publisher, error)

PublisherFactory is a simple function wrapper for creating a pubsub.Publisher instance

type SubscribeRequest

type SubscribeRequest struct {
	Topic             string                       `protobuf:"bytes,1,opt,name=topic" json:"topic,omitempty"`
	SubscriptionId    string                       `protobuf:"bytes,2,opt,name=subscription_id,json=subscriptionId" json:"subscription_id,omitempty"`
	Filter            map[string]string            `` /* 132-byte string literal not displayed */
	RetentionPeriod   *google_protobuf.UInt64Value `protobuf:"bytes,4,opt,name=retention_period,json=retentionPeriod" json:"retention_period,omitempty"`
	VisibilityTimeout *google_protobuf.UInt64Value `protobuf:"bytes,5,opt,name=visibility_timeout,json=visibilityTimeout" json:"visibility_timeout,omitempty"`
}

func (*SubscribeRequest) Descriptor

func (*SubscribeRequest) Descriptor() ([]byte, []int)

func (*SubscribeRequest) GetFilter

func (m *SubscribeRequest) GetFilter() map[string]string

func (*SubscribeRequest) GetRetentionPeriod added in v0.2.1

func (m *SubscribeRequest) GetRetentionPeriod() *google_protobuf.UInt64Value

func (*SubscribeRequest) GetSubscriptionId

func (m *SubscribeRequest) GetSubscriptionId() string

func (*SubscribeRequest) GetTopic

func (m *SubscribeRequest) GetTopic() string

func (*SubscribeRequest) GetVisibilityTimeout added in v0.2.1

func (m *SubscribeRequest) GetVisibilityTimeout() *google_protobuf.UInt64Value

func (*SubscribeRequest) ProtoMessage

func (*SubscribeRequest) ProtoMessage()

func (*SubscribeRequest) Reset

func (m *SubscribeRequest) Reset()

func (*SubscribeRequest) String

func (m *SubscribeRequest) String() string

type SubscribeResponse

type SubscribeResponse struct {
	MessageId string            `protobuf:"bytes,1,opt,name=message_id,json=messageId" json:"message_id,omitempty"`
	Message   []byte            `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Metadata  map[string]string `` /* 136-byte string literal not displayed */
}

func (*SubscribeResponse) Descriptor

func (*SubscribeResponse) Descriptor() ([]byte, []int)

func (*SubscribeResponse) GetMessage

func (m *SubscribeResponse) GetMessage() []byte

func (*SubscribeResponse) GetMessageId

func (m *SubscribeResponse) GetMessageId() string

func (*SubscribeResponse) GetMetadata

func (m *SubscribeResponse) GetMetadata() map[string]string

func (*SubscribeResponse) ProtoMessage

func (*SubscribeResponse) ProtoMessage()

func (*SubscribeResponse) Reset

func (m *SubscribeResponse) Reset()

func (*SubscribeResponse) String

func (m *SubscribeResponse) String() string

type SubscriberFactory

type SubscriberFactory func(context.Context, string, string) (pubsub.Subscriber, error)

SubscriberFactory is a simple function wrapper for creating a pubsub.Subscriber instance

Jump to

Keyboard shortcuts

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