theta

package module
v0.0.0-...-692109b Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: MIT Imports: 24 Imported by: 0

README

theta

Building lambda functions with ease

Documentation License Build Status Coverage Go Report Card

Overview

Theta is a minimalistic package on top of AWS packages. It provides a way to build a set of lambda functions that handles different events from different source (kinesis, sqs, dynamodb).

Installation

$ go get -u github.com/phogolabs/theta

Contributing

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudWatchHandler

type CloudWatchHandler struct {
	EventHandler EventHandler
}

CloudWatchHandler handles cloud watch cron jobs

func (*CloudWatchHandler) HandleContext

func (h *CloudWatchHandler) HandleContext(ctx context.Context, input events.CloudWatchEvent) error

HandleContext dispatches the command to the executor

type CompositeEventHandler

type CompositeEventHandler []EventHandler

CompositeEventHandler composes the event handler

func (CompositeEventHandler) HandleContext

func (h CompositeEventHandler) HandleContext(ctx context.Context, args *EventArgs) error

HandleContext handles event

type DictionaryEventHandler

type DictionaryEventHandler map[string]EventHandler

DictionaryEventHandler represents a dictionary of event handler

func (DictionaryEventHandler) HandleContext

func (h DictionaryEventHandler) HandleContext(ctx context.Context, args *EventArgs) error

HandleContext handles event

type DynamoHandler

type DynamoHandler struct {
	EventEncoder EventEncoder
	EventHandler EventHandler
}

DynamoHandler creates commands and dispatch them

func (*DynamoHandler) HandleContext

func (r *DynamoHandler) HandleContext(ctx context.Context, input events.DynamoDBEvent) error

HandleContext dispatches the command to the executor

type Event

type Event struct {
	ID        string    `json:"id" validate:"required"`
	Name      string    `json:"name" validate:"required"`
	Source    string    `json:"source" validate:"required"`
	Sender    string    `json:"sender" validate:"required"`
	Timestamp time.Time `json:"timestamp" validate:"required"`
}

Event represents a event's information

type EventArgs

type EventArgs struct {
	Event *Event          `json:"event" validate:"required"`
	Meta  Metadata        `json:"meta" validate:"-"`
	Body  json.RawMessage `json:"body" validate:"required"`
}

EventArgs is the actual event

type EventDecoder

type EventDecoder interface {
	Decode([]byte, interface{}) error
}

EventDecoder represents an event decoder

type EventEncoder

type EventEncoder interface {
	Encode(interface{}) ([]byte, error)
}

EventEncoder represents an event decoder

type EventHandler

type EventHandler interface {
	// HandleContext handles event
	HandleContext(ctx context.Context, args *EventArgs) error
}

EventHandler represents the event's handler

type GatewayHandler

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

GatewayHandler represents a webhook

func (*GatewayHandler) HandleContext

HandleContext handles the API Gateway Proxy Request

func (*GatewayHandler) Mount

func (h *GatewayHandler) Mount(route GatewayRoute)

Group returns the router.

func (*GatewayHandler) Use

Use use a given interceptor.

type GatewayHandlerAuth

type GatewayHandlerAuth struct {
	// Credentials keeps a map of the registered credentials
	Config *GatewayHandlerAuthConfig
}

GatewayHandlerAuth represents a authentication handler

func (*GatewayHandlerAuth) HandleContext

HandleContext handles the authorization request

type GatewayHandlerAuthConfig

type GatewayHandlerAuthConfig struct {
	Users []*GatewayHandlerAuthUserConfig
}

AuthConfig represents an auth configuration.

type GatewayHandlerAuthUserConfig

type GatewayHandlerAuthUserConfig struct {
	Name     string
	Password string
}

GatewayHandlerAuthUserConfig represents an user configuration.

type GatewayInterceptor

type GatewayInterceptor func(http.Handler) http.Handler

GatewayInterceptor represents a gateway interceptor

type GatewayRoute

type GatewayRoute interface {
	Mount(r chi.Router)
}

GatewayRoute represents a gateway route

type KinesisClient

type KinesisClient = kinesisiface.KinesisAPI

KinesisClient creates a new client

type KinesisCollector

type KinesisCollector struct {
	Scanner      KinesisScanner
	EventHandler EventHandler
	EventDecoder EventDecoder
	Cancel       context.CancelFunc
}

KinesisCollector handles kinesis stream

func NewKinesisCollector

func NewKinesisCollector(config *KinesisCollectorConfig) *KinesisCollector

NewKinesisCollector creates a new collector to kinesis

func (*KinesisCollector) CollectContext

func (h *KinesisCollector) CollectContext(ctx context.Context) error

CollectContext handles the kinesis stream

func (*KinesisCollector) CollectContextAsync

func (h *KinesisCollector) CollectContextAsync(ctx context.Context) error

CollectContextAsync handles the kinesis stream asyncronosly

type KinesisCollectorConfig

type KinesisCollectorConfig struct {
	RoleArn      string
	Region       string
	StreamName   string
	Options      []KinesisCollectorOption
	EventHandler EventHandler
}

KinesisCollectorConfig represents the kinesis collector config

type KinesisCollectorOption

type KinesisCollectorOption = consumer.Option

KinesisCollectorOption represents a collector options

func KinesisCollectorWithStore

func KinesisCollectorWithStore(store KinesisCollectorStore) KinesisCollectorOption

KinesisCollectorWithStore creates a store option

type KinesisCollectorStore

type KinesisCollectorStore = consumer.Store

KinesisCollectorStore represents a kinesis collector store

func NewKinesisCollectorPSQLStore

func NewKinesisCollectorPSQLStore(name, table string, url string) (KinesisCollectorStore, error)

NewKinesisCollectorPSQLStore creates a new PostgreSQL store

type KinesisDispatcher

type KinesisDispatcher struct {
	StreamName string
	Client     KinesisClient
}

KinesisDispatcher dispatches event to kinesis bus

func NewKinesisDispatcher

func NewKinesisDispatcher(config *KinesisDispatcherConfig) *KinesisDispatcher

NewKinesisDispatcher creates a new dispatcher to kinesis

func (*KinesisDispatcher) HandleContext

func (d *KinesisDispatcher) HandleContext(ctx context.Context, args *EventArgs) error

HandleContext handles event

type KinesisDispatcherConfig

type KinesisDispatcherConfig struct {
	RoleArn    string
	Region     string
	StreamName string
}

KinesisDispatcherConfig represents the kinesis dispatcher config

type KinesisHandler

type KinesisHandler struct {
	EventHandler EventHandler
	EventDecoder EventDecoder
}

KinesisHandler reacts on events

func (*KinesisHandler) HandleContext

func (h *KinesisHandler) HandleContext(ctx context.Context, input events.KinesisEvent) error

HandleContext dispatches the event to the handler

func (*KinesisHandler) ServeHTTP

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

ServerHTTP serves a http request

type KinesisRecord

type KinesisRecord = consumer.Record

KinesisRecord represents a strem record

type KinesisScanFunc

type KinesisScanFunc = consumer.ScanFunc

KinesisScanFunc is a function executed on kinesis input stream

type KinesisScanner

type KinesisScanner interface {
	Scan(ctx context.Context, fn KinesisScanFunc) error
}

KinesisScanner scans kinesis stream

type Metadata

type Metadata map[string]string

Metadata information

func (Metadata) Get

func (m Metadata) Get(key string) string

Get returns a value for given key

type SQSClient

type SQSClient = sqsiface.SQSAPI

SQSClient creates a new client

type SQSDispatcher

type SQSDispatcher struct {
	// QueueURL address
	QueueURL string
	// Clinet for the SQS
	Client SQSClient
}

SQSDispatcher dispatches a command via SQS

func (*SQSDispatcher) HandleContext

func (r *SQSDispatcher) HandleContext(ctx context.Context, args *EventArgs) error

HandleContext dispatches an event to SQS

type SQSHandler

type SQSHandler struct {
	EventHandler EventHandler
}

SQSHandler dispatches the commands

func (*SQSHandler) HandleContext

func (r *SQSHandler) HandleContext(ctx context.Context, input events.SQSEvent) error

HandleContext dispatches the command to the underlying executors

type XrayEventHandler

type XrayEventHandler struct {
	Segment      string
	Metadata     map[string]interface{}
	EventHandler EventHandler
}

XrayEventHandler is a handler that add XRay segment

func (*XrayEventHandler) HandleContext

func (h *XrayEventHandler) HandleContext(ctx context.Context, args *EventArgs) error

HandleContext handles the event

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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