gizmo: github.com/NYTimes/gizmo/pubsub/http Index | Files

package http

import "github.com/NYTimes/gizmo/pubsub/http"

Index

Package Files

pub.go

type GCPPublisher Uses

type GCPPublisher struct {
    pubsub.Publisher
}

GCPPublisher publishes data in the same format as a GCP push-style payload.

func NewGCPStylePublisher Uses

func NewGCPStylePublisher(url string, client *http.Client) GCPPublisher

NewGCPStylePublisher will return a pubsub.Publisher that wraps the payload in a GCP pubsub.Message-like object that will make this publisher emulate Google's PubSub posting messages to a server. If no http.Client is provided, the default one has a 5 second timeout.

func (GCPPublisher) Publish Uses

func (p GCPPublisher) Publish(ctx context.Context, key string, msg proto.Message) error

Publish will serialize the given message and pass it to PublishRaw.

func (GCPPublisher) PublishMulti Uses

func (p GCPPublisher) PublishMulti(ctx context.Context, keys []string, msgs []proto.Message) error

PublishMulti will serialize the given messages and pass them to PublishMultiRaw.

func (GCPPublisher) PublishMultiRaw Uses

func (p GCPPublisher) PublishMultiRaw(ctx context.Context, _ []string, msgs [][]byte) error

PublishMultiRaw will call PublishRaw for each message given.

func (GCPPublisher) PublishRaw Uses

func (p GCPPublisher) PublishRaw(ctx context.Context, key string, msg []byte) error

PublishRaw will wrap the given message in a struct similar to GCP's push-style PubSub subscriptions and then POST the message payload at the URL provided in the construct.

type Publisher Uses

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

Publisher implements the pubsub.Publisher and MultiPublisher interfaces for use in a plain HTTP environment.

func NewPublisher Uses

func NewPublisher(url string, client *http.Client) Publisher

NewPublisher will return a pubsub.Publisher that simply posts the payload to the given URL. If no http.Client is provided, the default one has a 5 second timeout.

func (Publisher) Publish Uses

func (p Publisher) Publish(ctx context.Context, key string, msg proto.Message) error

Publish will serialize the given message and pass it to PublishRaw.

func (Publisher) PublishMulti Uses

func (p Publisher) PublishMulti(ctx context.Context, keys []string, msgs []proto.Message) error

PublishMulti will serialize the given messages and pass them to PublishMultiRaw.

func (Publisher) PublishMultiRaw Uses

func (p Publisher) PublishMultiRaw(ctx context.Context, _ []string, msgs [][]byte) error

PublishMultiRaw will call PublishRaw for each message given.

func (Publisher) PublishRaw Uses

func (p Publisher) PublishRaw(_ context.Context, _ string, payload []byte) error

PublishRaw will POST the given message payload at the URL provided in the Publisher construct.

Package http imports 9 packages (graph). Updated 2019-03-10. Refresh now. Tools for package owners.