google

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: MIT Imports: 7 Imported by: 3

Documentation

Overview

Package google is a wrapper of the original "cloud.google.com/go/pubsu" library.

Only contains basic publish, subscribe, and close methods. Data will be encoded to JSON before publishing the message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

Channel is google pubsub channel.

func (*Channel) Close

func (c *Channel) Close() error

Close to close subscription.

func (*Channel) Read

func (c *Channel) Read(ctx context.Context, model interface{}) (<-chan interface{}, <-chan error)

Read to read incoming message.

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client is google pubsub client.

func New

func New(projectID, serviceAccountCredentialPath string) (*Client, error)

New to create new google pubsub client.

Required google service account credential. https://cloud.google.com/pubsub/docs/publish-receive-messages-client-library.

If haven't set env "GOOGLE_APPLICATION_CREDENTIALS", you can provide the credential json file path in the param.

func (*Client) Close

func (c *Client) Close() error

Close to close pubsub connection.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, topic string, data interface{}) error

Publish to publish message.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, topic string) (interface{}, error)

Subscribe to subscribe to a topic.

Need to convert the return type to pubsub.Channel.

Jump to

Keyboard shortcuts

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