notifications

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package notifications is a basic internal notifications module

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the client (configuration)

func (*Client) Debug

func (c *Client) Debug(on bool)

Debug will set the debug flag

func (*Client) GetWebhookEndpoint

func (c *Client) GetWebhookEndpoint() string

GetWebhookEndpoint will get the configured webhook endpoint

func (*Client) IsDebug

func (c *Client) IsDebug() bool

IsDebug will return if debugging is enabled

func (*Client) Logger

func (c *Client) Logger() *zerolog.Logger

Logger get the logger

func (*Client) Notify

func (c *Client) Notify(ctx context.Context, modelType string, eventType EventType,
	model interface{}, id string) error

Notify will create a new notification event

type ClientInterface

type ClientInterface interface {
	Debug(on bool)
	GetWebhookEndpoint() string
	IsDebug() bool
	Logger() *zerolog.Logger
	Notify(ctx context.Context, modelType string, eventType EventType, model interface{}, id string) error
}

ClientInterface is the notification client interface

func NewClient

func NewClient(opts ...ClientOps) (ClientInterface, error)

NewClient creates a new client for notifications

type ClientOps

type ClientOps func(c *clientOptions)

ClientOps allow functional options to be supplied that overwrite default client options.

func WithDebugging

func WithDebugging() ClientOps

WithDebugging will set debugging on notifications

func WithLogger

func WithLogger(customLogger *zerolog.Logger) ClientOps

WithLogger will set the logger

func WithNotifications

func WithNotifications(webhookEndpoint string) ClientOps

WithNotifications will set the webhook endpoint

type EventType

type EventType string

EventType event types thrown in Bux

const (
	// EventTypeCreate when a new model is created
	EventTypeCreate EventType = "create"

	// EventTypeUpdate when a new model is updated
	EventTypeUpdate EventType = "update"

	// EventTypeDelete when a new model is deleted
	EventTypeDelete EventType = "delete"

	// EventTypeBroadcast when a transaction is broadcasted (sync tx)
	EventTypeBroadcast EventType = "broadcast"
)

type HTTPInterface

type HTTPInterface interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPInterface is the HTTP client interface

Jump to

Keyboard shortcuts

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