cloud

package module
v0.0.0-...-69af3c4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 12 Imported by: 0

README

cloud

Documentation License Build Status Coverage Go Report Card

Cloud package enables cloudevents.io for server less

Installation

Make sure you have a working Go environment. Go version 1.13.x is supported.

See the install instructions for Go.

To install cloud, simply run:

$ go get github.com/phogolabs/cloud

Contributing

We are open for any contributions. Just fork the project.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NewEvent returns a new Event, an optional version can be passed to change the
	// default spec version from 1.0 to the provided version.
	NewEvent = v2.NewEvent

	// NewClient creates a new client
	NewClient = v2.NewClient

	// NewHTTP creates a new http protocol
	NewHTTP = v2.NewHTTP

	// NewHTTPReceiveHandler creates a new HTTP handler
	NewHTTPReceiveHandler = v2.NewHTTPReceiveHandler

	// AddFormat adds a new Format. It can be retrieved by Lookup(f.MediaType())
	AddFormat = format.Add
)
View Source
var (
	TextPlain                       = v2.TextPlain
	ApplicationXML                  = v2.ApplicationXML
	ApplicationJSON                 = v2.ApplicationJSON
	ApplicationCloudEventsJSON      = v2.ApplicationCloudEventsJSON
	ApplicationCloudEventsBatchJSON = v2.ApplicationCloudEventsBatchJSON
)
View Source
var WithLogger = context.WithLogger

WithLogger returns a new context with the logger injected into the given context.

Functions

This section is empty.

Types

type Client

type Client = v2.Client

Client represents a client

type Dictionary

type Dictionary = map[string]interface{}

Dictionary represents a dictionary

type Event

type Event = v2.Event

Event represents the canonical representation of a CloudEvent.

func NewEventWith

func NewEventWith(args EventArgs) (*Event, error)

NewEventWith creates a new event for the provided args.

type EventArgs

type EventArgs interface {
	Type() string
	Source() string
	Subject() string
	DataSchema() string
	Extensions() Dictionary
	DataContentType() string
}

EventArgs represents the event arguments

type EventArgsAdapter

type EventArgsAdapter struct {
	// EventSender sends the actual event
	EventSender EventSender
}

EventArgsAdapter represents an event dispatcher

func (*EventArgsAdapter) Dispatch

func (d *EventArgsAdapter) Dispatch(ctx context.Context, args EventArgs) error

Dispatch dispatches a given event

type EventArgsComposer

type EventArgsComposer []EventArgsDispatcher

EventArgsCompoer represents an event dispatcher

func (EventArgsComposer) Dispatch

func (collection EventArgsComposer) Dispatch(ctx context.Context, args EventArgs) error

Dispatch dispatches a given event

type EventArgsConverter

type EventArgsConverter interface {
	// inherits from EventArgs
	EventArgs
	// DataAs converts the event arguments to the given type
	DataAs(interface{}) error
}

EventArgsConverter converts an event arguments

type EventArgsDispatcher

type EventArgsDispatcher interface {
	// Dispatch dispatches the event args
	Dispatch(context.Context, EventArgs) error
}

EventArgsDispatcher dispatches the events

type EventReceiver

type EventReceiver interface {
	Receive(ctx context.Context, eventArgs Event) Result
}

EventReceiver represents a receiver

type EventReceiverFunc

type EventReceiverFunc func(context.Context, Event) Result

EventReceiverFunc represents a receiver func

func (EventReceiverFunc) Receive

func (fn EventReceiverFunc) Receive(ctx context.Context, eventArgs Event) Result

Receive receives the event

type EventSender

type EventSender interface {
	// Send will transmit the given event over the client's configured transport.
	Send(ctx context.Context, event Event) Result
}

EventSender sends cloud events

type HTTPProtocol

type HTTPProtocol = v2.HTTPProtocol

HTTPProtocol represents the HTTP protocol

type NopEventSender

type NopEventSender struct{}

NopEventSender represent no-operation event sender

func (*NopEventSender) Send

func (n *NopEventSender) Send(ctx context.Context, args Event) Result

Send sends the event

type Result

type Result = v2.Result

Result represents the result

type Webhook

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

EventHandler handles the events received from pubsub topic

func NewWebhook

func NewWebhook() *Webhook

NewWebhook creates a new event handler

func (*Webhook) Mount

func (h *Webhook) Mount(pattern string, receiver EventReceiver)

Mount mounts the receiver to a given path

func (*Webhook) ServeHTTP

func (h *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request)

Mount mounts the receiver to a given path

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.
provider
gcp

Jump to

Keyboard shortcuts

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