webhook

package
v0.0.0-...-941f93f Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InMemory is an enum that represents the in-memory store
	InMemory = 0
	// Consul is an enum that represents the consul store
	Consul = 1
)
View Source
const (
	// Nats enum is the queue option
	Nats = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Label       string `json:"label"`
	Enabled     bool   `json:"enable"`
}

Event represents the individual events that are available for subscription

func BasicEvent

func BasicEvent(name string) Event

BasicEvent takes a name and return an Event

type Func

type Func func([]byte)

Func represents a function that takes byte as parameter type Func func(params []byte)

type Option

type Option func(*webhook)

Option returns a function to the pointer of webhook

func SetDescription

func SetDescription(desc string) Option

SetDescription takes a description and overwrites the default description

func SetName

func SetName(name string) Option

SetName takes a name and overwrites the default name

type Payload

type Payload struct {
	Subject   string
	RequestID string
	Body      interface{}
	SentAt    time.Time
}

Payload represents the message that is passed through the queue with additional metadata

type Queue

type Queue interface {
	Publish(evt string, payload []byte) error
	Subscribe(evt string, fn Func) error
}

Queue represents the interface for the queue

func NewNatsQueue

func NewNatsQueue() Queue

NewNatsQueue returns a new nats queue

func NewQueue

func NewQueue(opt int) Queue

NewQueue returns a new queue of choice

type Store

type Store interface {
	Put(key string, val []byte) error
	Get(key string) ([]byte, error)
	Delete(key string) error
	List(key string) ([]string, error)
}

Store represents the interface for the different stores available

func NewConsulStore

func NewConsulStore() Store

NewConsulStore returns a new consul store

func NewInMemoryStore

func NewInMemoryStore() Store

NewInMemoryStore returns a new in-memory store

func NewStore

func NewStore(store int8) Store

NewStore returns a new store based on the provided options

type Webhook

type Webhook interface {
	Register(events ...Event) error
	Unregister(name string) error
	Publish(name string, payload interface{}) error
	Subscribe(name string, fn Func) error
	Post(url string, payload []byte) error
	Disco(name string) error
	Fetch(event string) ([]string, error)
	Enable(resource, event, callbackURL string) error
	Disable(resource, event, callbackURL string) error
}

Webhook represents the interface for the webhook package

func New

func New(opts ...Option) Webhook

New returns a pointer to the webhook struct

Jump to

Keyboard shortcuts

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