handler

package
v0.0.0-...-cbcb865 Latest Latest
Warning

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

Go to latest
Published: May 16, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = internal.Logger

Logger is common logger gateway

Functions

func SetLogLevel

func SetLogLevel(level string)

func StartLambda

func StartLambda(handler Handler, reader ...*rlogs.Reader)

StartLambda initialize AWS Lambda and invokes handler

Types

type Arguments

type Arguments struct {
	EnvVars
	Event interface{}

	NewS3      adaptor.S3ClientFactory    `json:"-"`
	NewSQS     adaptor.SQSClientFactory   `json:"-"`
	ChunkRepo  repository.ChunkRepository `json:"-"`
	MetaRepo   repository.MetaRepository  `json:"-"`
	NewEncoder adaptor.EncoderFactory     `json:"-"`
	NewDecoder adaptor.DecoderFactory     `json:"-"`

	// Only required for indexer
	Reader *rlogs.Reader
}

Arguments has environment variables, Event record and adaptor

func (*Arguments) BindEvent

func (x *Arguments) BindEvent(ev interface{}) error

BindEvent directly decode event data and unmarshal to ev object.

func (*Arguments) ChunkService

func (x *Arguments) ChunkService() *service.ChunkService

ChunkService provides ChunkRepository implementation (DynamoDB)

func (*Arguments) DecapSQSEvent

func (x *Arguments) DecapSQSEvent() ([]EventRecord, error)

DecapSQSEvent decapslates wrapped body data in SQSEvent

func (*Arguments) MetaService

func (x *Arguments) MetaService() *service.MetaService

func (*Arguments) RecordService

func (x *Arguments) RecordService() *service.RecordService

RecordService provides encode/decode logic and S3 access for normalized log data

func (*Arguments) S3Service

func (x *Arguments) S3Service() *service.S3Service

S3Service provides service.S3Service with S3 adaptor

func (*Arguments) SQSService

func (x *Arguments) SQSService() *service.SQSService

SQSService provides service.SQSService with SQS adaptor

type EnvVars

type EnvVars struct {
	// From arguments
	AthenaDBName string `env:"ATHENA_DB_NAME"`
	S3Region     string `env:"S3_REGION"`
	S3Bucket     string `env:"S3_BUCKET"`
	S3Prefix     string `env:"S3_PREFIX"`
	SentryDSN    string `env:"SENTRY_DSN"`
	SentryEnv    string `env:"SENTRY_ENVIRONMENT"`
	LogLevel     string `env:"LOG_LEVEL"`

	// From resource
	MetaTableName     string `env:"META_TABLE_NAME"`
	ChunkTableName    string `env:"CHUNK_TABLE_NAME"`
	PartitionQueueURL string `env:"PARTITION_QUEUE_URL"`
	ComposeQueueURL   string `env:"COMPOSE_QUEUE_URL"`
	MergeQueueURL     string `env:"MERGE_QUEUE_URL"`

	// From AWS Lambda
	AwsRegion string `env:"AWS_REGION"`
}

EnvVars has all environment variables that should be given to Lambda function

func (*EnvVars) BindEnvVars

func (x *EnvVars) BindEnvVars() error

BindEnvVars loads environments variables and set them to EnvVars

type EventRecord

type EventRecord []byte

EventRecord is decapslated event data (e.g. Body of SQS event)

func (EventRecord) Bind

func (x EventRecord) Bind(ev interface{}) error

Bind unmarshal event record to object

type Handler

type Handler func(Arguments) error

Handler has main logic of the lambda function

Jump to

Keyboard shortcuts

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