message_queue

package
v0.0.0-...-045890f Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageQueue

type MessageQueue interface {
	Init(pubSubKey string, gProject string) error
	Close() error
	Publish(string, *PubSubData) *goPubSub.PublishResult
	GetResult(ctx context.Context, result *goPubSub.PublishResult) (string, error)
	SubscribeMessages(ctx context.Context, subscriptionId string, subscribeFunction SubscribeFunction) error
}

MessageQueue Intergace to the wrappers around Google pubsub lib calls

func NewMessageQueue

func NewMessageQueue(enabled bool, serviceAccountKey string, project string) MessageQueue

NewMessageQueue create a new object to MessageQueue interface

type PubSubData

type PubSubData struct {
	Id        string
	Timestamp int64
	Data      []byte
}

PubSubData represents msg format to be used for writing messages to pubsub

type PubSubQueue

type PubSubQueue struct {
	PubsubClient *goPubSub.Client
	// contains filtered or unexported fields
}

PubSubQueue Required configs for interacting with pubsub

func (*PubSubQueue) Close

func (pubsubqueue *PubSubQueue) Close() error

Close Closes all topic connections to pubsub

func (*PubSubQueue) GetResult

func (pubsubqueue *PubSubQueue) GetResult(ctx context.Context, result *goPubSub.PublishResult) (string, error)

GetResult gets results of the publish call, can be used to make publish a sync call

func (*PubSubQueue) Init

func (pubsubqueue *PubSubQueue) Init(pubSubKey string, gProject string) error

Init initiates connection to Google Pubsub

func (*PubSubQueue) Publish

func (pubsubqueue *PubSubQueue) Publish(topicName string, pubSubData *PubSubData) *goPubSub.PublishResult

Publish publishes the given message to the topic

func (*PubSubQueue) SubscribeMessages

func (pubsubqueue *PubSubQueue) SubscribeMessages(ctx context.Context, subscriptionId string, subscribeFunction SubscribeFunction) error

SubscribeMessages Initales a subscriber call and assigns to given subscriber function

type SubscribeFunction

type SubscribeFunction func(ctx context.Context, msg *goPubSub.Message)

SubscribeFunction receives messages from a subscription

Directories

Path Synopsis
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

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