common

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(env string, defaultValue string) string

GetEnv returns an environment. The defaultValue is returned if the variable does not exist.

func GetEnvInt

func GetEnvInt(env string, defaultValue int) int

GetEnvInt returns an environment that is required to be an integer

func PrepareSNSMessageJSON

func PrepareSNSMessageJSON(body interface{}) (string, error)

PrepareSNSMessageJSON creates a JSON message from a struct, for publising to an SNS topic

func RequireEnv

func RequireEnv(env string) string

RequireEnv validates and returns an environment variable's value if it exists

func RequireEnvFloat

func RequireEnvFloat(env string) float64

RequireEnvFloat returns an environment that is required to be an float64

func RequireEnvFloatSlice

func RequireEnvFloatSlice(env string, sep string) []float64

RequireEnvFloatSlice - Requires the given environment variable to contain a slice of float64

func RequireEnvInt

func RequireEnvInt(env string) int

RequireEnvInt returns an environment that is required to be an integer

func RequireEnvStringSlice

func RequireEnvStringSlice(env string, sep string) []string

RequireEnvStringSlice - Requires the given environment variable to contain a slice of string

Types

type DefaultEnvConfig

type DefaultEnvConfig struct{}

DefaultEnvConfig - Default configuration

func (DefaultEnvConfig) GetEnvBoolVar

func (cfg DefaultEnvConfig) GetEnvBoolVar(varName string, defaultValue bool) bool

GetEnvBoolVar - Requires the environment variable with the provided varName

and panics if the variable is not present.

func (DefaultEnvConfig) GetEnvFloatVar

func (cfg DefaultEnvConfig) GetEnvFloatVar(varName string, defaultValue float64) float64

GetEnvFloatVar - Requires the environment variable with the provided varName

and panics if the variable is not present

func (DefaultEnvConfig) GetEnvIntVar

func (cfg DefaultEnvConfig) GetEnvIntVar(varName string, defaultValue int) int

GetEnvIntVar - Requires the environment variable with the provided varName

and panics if the variable is not present.

func (DefaultEnvConfig) GetEnvVar

func (cfg DefaultEnvConfig) GetEnvVar(varName string, defaultValue string) string

GetEnvVar - Requires the environment variable with the provided varName

and panics if the variable is not present.

func (DefaultEnvConfig) RequireEnvIntVar

func (cfg DefaultEnvConfig) RequireEnvIntVar(varName string) int

RequireEnvIntVar - Requires the environment variable with the provided varName

and panics if the variable is not present.

func (DefaultEnvConfig) RequireEnvVar

func (cfg DefaultEnvConfig) RequireEnvVar(varName string) string

RequireEnvVar - Requires the environment variable with the provided varName

and panics if the variable is not present.

type EnvConfig

type EnvConfig interface {
	RequireEnvVar(varName string) string
	RequireEnvIntVar(varName string) int
	GetEnvVar(varName string, defaultValue string) string
	GetEnvIntVar(varName string, defaultValue int) int
	GetEnvFloatVar(varName string, defaultValue float64) float64
}

EnvConfig - Configuration pulled from the environment.

type Notificationer

type Notificationer interface {
	PublishMessage(topicArn *string, message *string, isJSON bool) (*string, error)
}

Notificationer interface requires methods to interact with an AWS SNS Topic and publish a message to it

type Queue

type Queue interface {
	SendMessage(*string, *string) error
	ReceiveMessage(*sqs.ReceiveMessageInput) (*sqs.ReceiveMessageOutput, error)
	DeleteMessage(*sqs.DeleteMessageInput) (*sqs.DeleteMessageOutput, error)
	NewFromEnv() error
}

Queue interface requires a method to receive an SQS Message Output based on the provided SQS Message Input

type S3

type S3 struct {
	Client  *s3.S3
	Manager *s3manager.Downloader
}

S3 implements the Storage interface using AWS S3 Client

func (S3) Download

func (stor S3) Download(bucket string, key string, filepath string) error

Download downloads an S3 Bucket object to the file path provided and returns any errors if any

func (S3) GetObject

func (stor S3) GetObject(bucket string, key string) (string, error)

GetObject returns a string output based on the results of the retrieval of an existing object from S3

func (S3) GetObjectWithETag

func (stor S3) GetObjectWithETag(bucket string, key string) (string, string, error)

GetObjectWithETag returns a string output based on the results of the retrieval of an existing object from S3

func (S3) GetTemplateObject

func (stor S3) GetTemplateObject(bucket string, key string, input interface{}) (string, string, error)

GetTemplateObject returns a string output based on the results of the retrieval of an existing object from S3

type SNS

type SNS struct {
	Client *sns.SNS
}

SNS implements the Notification interface with AWS SNS SDK

func (*SNS) PublishMessage

func (notif *SNS) PublishMessage(topicArn *string, message *string,
	isJSON bool) (*string, error)

PublishMessage pushes the provided messeage to an SNS Topic and returns the messages' ID.

type SQSQueue

type SQSQueue struct {
	Client *sqs.SQS
}

SQSQueue implments the Queue interface using the AWS SQS Service

func (SQSQueue) DeleteMessage

func (queue SQSQueue) DeleteMessage(input *sqs.DeleteMessageInput) (
	*sqs.DeleteMessageOutput, error)

DeleteMessage method returns an AWS SQS Delete Message Output based on the provided Delete Message Input through the SQS Client

func (SQSQueue) NewFromEnv

func (queue SQSQueue) NewFromEnv() error

NewFromEnv creates an SQS instance configured from environment variables. Requires env vars for: - AWS_CURRENT_REGION

func (SQSQueue) ReceiveMessage

func (queue SQSQueue) ReceiveMessage(input *sqs.ReceiveMessageInput) (
	*sqs.ReceiveMessageOutput, error)

ReceiveMessage method returns an AWS SQS Message Output based on the provided Message Input through the AWS SQS Client.

func (SQSQueue) SendMessage

func (queue SQSQueue) SendMessage(queueURL *string, message *string) error

SendMessage sends the provided message to the queue using the AWS SQS Service and returns an errors

type STS

type STS struct {
	Client *sts.STS
}

STS implements the TokenService interface using AWS STS Client

func (STS) AssumeRole

func (service STS) AssumeRole(input *sts.AssumeRoleInput) (
	*sts.AssumeRoleOutput, error)

AssumeRole returns an STS AssumeRoleOutput struct based on the provided input through the AWS STS Client

func (STS) NewCredentials

func (service STS) NewCredentials(inputClient client.ConfigProvider,
	inputRole string) *credentials.Credentials

NewCredentials returns a set of credentials for an Assume Role

func (STS) NewSession

func (service STS) NewSession(baseSession awsiface.AwsSession, roleArn string) (awsiface.AwsSession, error)

type Storager

type Storager interface {
	GetObject(bucket string, key string) (string, error)
	GetTemplateObject(bucket string, key string, input interface{}) (string, string, error)
	Download(bukcet string, key string, filepath string) error
}

Storager interface requires a method to delete an S3 Object from a Bucket based on the provided S3 Object Input

type TokenService

type TokenService interface {
	AssumeRole(*sts.AssumeRoleInput) (*sts.AssumeRoleOutput, error)
	NewCredentials(client.ConfigProvider, string) *credentials.Credentials
	NewSession(baseSession awsiface.AwsSession, roleArn string) (awsiface.AwsSession, error)
}

TokenService interface requires a method to receive credentials for an AWS Role provided by the Role Input.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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