extensions

package
v3.1.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateFakeID

func GenerateFakeID(size int) string

GenerateFakeID generates an id with a FAKE- prefix

func GenerateID

func GenerateID(size int) string

GenerateID generates a an id with the given size

func NewRedis

func NewRedis(prefix string, conf *viper.Viper, logger zap.Logger) (*redis.Client, error)

NewRedis connection with the specified configuration

func NewS3

func NewS3(conf *viper.Viper, logger zap.Logger) (interfaces.S3, error)

NewS3 client with the specified configuration

Types

type AmazonS3

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

AmazonS3 contain information related to S3

func (*AmazonS3) CompleteMultipartUpload

func (am *AmazonS3) CompleteMultipartUpload(multipartUpload *s3.CreateMultipartUploadOutput, parts []*s3.CompletedPart) error

CompleteMultipartUpload end a multipart upload

func (*AmazonS3) DownloadChunk

func (am *AmazonS3) DownloadChunk(start, size int64, path string) (int, *bytes.Buffer, error)

DownloadChunk downloads the chunk from s3

func (*AmazonS3) GetObject

func (am *AmazonS3) GetObject(path string) ([]byte, error)

GetObject gets an object from s3

func (*AmazonS3) InitMultipartUpload

func (am *AmazonS3) InitMultipartUpload(path string) (*s3.CreateMultipartUploadOutput, error)

InitMultipartUpload build obeject to send multipart

func (*AmazonS3) PutObject

func (am *AmazonS3) PutObject(path string, body *[]byte) (*s3.PutObjectOutput, error)

PutObject puts an object into s3.

func (*AmazonS3) PutObjectRequest

func (am *AmazonS3) PutObjectRequest(path string) (string, error)

PutObjectRequest return a presigned url for uploading a file to s3

func (*AmazonS3) UploadPart

func (am *AmazonS3) UploadPart(input *bytes.Buffer, multipartUpload *s3.CreateMultipartUploadOutput,
	partNumber int64) (*s3.UploadPartOutput, error)

UploadPart get a piece of multipart and upload a buffer to this part. The buffer must have at least 5mb and the maximum of 100mb. The last part can be smaller than 5mb

type KafkaProducer added in v1.0.0

type KafkaProducer struct {
	Config           *viper.Viper
	ConfigPath       string
	Logger           zap.Logger
	BootstrapBrokers string
	FlushMaxMessages int
	FlushFrequency   int // ms
	Producer         sarama.AsyncProducer
	Statsd           *statsd.Client
	MaxMessageBytes  int
	Retries          int
}

KafkaProducer is the struct that connects to Kafka

func NewKafkaProducer added in v1.0.0

func NewKafkaProducer(config *viper.Viper, logger zap.Logger, statsd *statsd.Client) (*KafkaProducer, error)

NewKafkaProducer creates a new kafka producer

func (*KafkaProducer) Close added in v1.0.0

func (c *KafkaProducer) Close()

Close the connections to kafka

func (*KafkaProducer) SendAPNSPush added in v1.0.0

func (c *KafkaProducer) SendAPNSPush(topic, deviceToken string, payload, messageMetadata map[string]interface{}, pushMetadata map[string]interface{}, pushExpiry int64, templateName string) error

SendAPNSPush notification to Kafka

func (*KafkaProducer) SendGCMPush added in v1.0.0

func (c *KafkaProducer) SendGCMPush(topic, deviceToken string, payload, messageMetadata map[string]interface{}, pushMetadata map[string]interface{}, pushExpiry int64, templateName string) error

SendGCMPush notification to Kafka

type PGClient

type PGClient struct {
	Config *viper.Viper
	DB     interfaces.DB
	Logger zap.Logger
}

PGClient is the struct that connects to PostgreSQL

func NewPGClient

func NewPGClient(prefix string, config *viper.Viper, logger zap.Logger, PGOrNil ...interfaces.DB) (*PGClient, error)

NewPGClient creates a new client

func (*PGClient) Close

func (c *PGClient) Close() error

Close the connections to PG

func (*PGClient) Connect

func (c *PGClient) Connect(prefix string, PGOrNil ...interfaces.DB) error

Connect to PG

func (*PGClient) IsConnected

func (c *PGClient) IsConnected() bool

IsConnected determines if the client is connected to PG

func (*PGClient) WaitForConnection

func (c *PGClient) WaitForConnection(timeout int) error

WaitForConnection loops until postgres is connected

type RedisConnectionError

type RedisConnectionError struct {
	SourceError error
}

RedisConnectionError with SourceError that originated the connection failure

func (*RedisConnectionError) Error

func (e *RedisConnectionError) Error() string

type SendgridClient

type SendgridClient struct {
	Config *viper.Viper
	Logger zap.Logger
	APIKey string
}

SendgridClient is the struct that keeps sendgrid info

func NewSendgridClient

func NewSendgridClient(config *viper.Viper, logger zap.Logger, apiKey string) *SendgridClient

NewSendgridClient creates a new client

func (*SendgridClient) LoadDefaults

func (c *SendgridClient) LoadDefaults()

LoadDefaults sets default values for keys needed by this module

func (*SendgridClient) SendgridSendEmail

func (c *SendgridClient) SendgridSendEmail(addressee, subject, message string, skipBlacklist bool) error

SendgridSendEmail sends an email with the given message and addressee

Jump to

Keyboard shortcuts

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