gateways

package
v0.0.0-...-8341997 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2017 License: MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseService

type BaseService struct {
	Client *http.Client
}

BaseService has generic methods for sending and parsing expresso service

responses

func NewBaseService

func NewBaseService() *BaseService

NewBaseService returns a BaseService with the default http Client

func (*BaseService) ServiceSend

func (b *BaseService) ServiceSend(method string, url string, data interface{}, i interface{}) error

ServiceSend sends a request of type METHOD to the url with data as the

JSON payload and puts the response into i

type Bloodlines

type Bloodlines interface {
	GetAllContent(offset int, limit int) ([]*models.Content, error)
	NewContent(newContent *models.Content) (*models.Content, error)
	GetContentByID(id uuid.UUID) (*models.Content, error)
	UpdateContent(update *models.Content) (*models.Content, error)
	DeleteContent(id uuid.UUID) error
	GetAllReceipts(offset int, limit int) ([]*models.Receipt, error)
	SendReceipt(receipt *models.Receipt) (*models.Receipt, error)
	GetReceiptByID(id uuid.UUID) (*models.Receipt, error)
	GetAllTriggers(offset int, limit int) ([]*models.Trigger, error)
	NewTrigger(t *models.Trigger) (*models.Trigger, error)
	GetTriggerByKey(key string) (*models.Trigger, error)
	UpdateTrigger(update *models.Trigger) (*models.Trigger, error)
	DeleteTrigger(key string) error
	ActivateTrigger(key string, receipt *models.Receipt) (*models.SendRequest, error)
	NewPreference(id uuid.UUID) (*models.Preference, error)
	GetPreference(id uuid.UUID) (*models.Preference, error)
	UpdatePreference(*models.Preference) (*models.Preference, error)
	DeletePreference(id uuid.UUID) error
}

Bloodlines wraps all the methods of the bloodlines API

func NewBloodlines

func NewBloodlines(config config.Bloodlines) Bloodlines

NewBloodlines creates and returns a Bloodlines struct pointed at the service denoted in config

type MySQL

type MySQL struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

MySQL implements SQL with the mysql driver

func NewSQL

func NewSQL(config config.MySQL) (*MySQL, error)

NewSQL returns an instance of MySQL with the given connection configuration

func (*MySQL) Destroy

func (s *MySQL) Destroy()

Destroy cleans up the MySQL instance

func (*MySQL) Modify

func (s *MySQL) Modify(query string, values ...interface{}) error

Modify executes any query which changes the db and doesn't return result rows

func (*MySQL) Select

func (s *MySQL) Select(query string, values ...interface{}) (*sql.Rows, error)

Select gets rows from a select query

type Rabbit

type Rabbit struct {
	Conn    *amqp.Connection
	Channel *amqp.Channel
	Queue   *amqp.Queue
	Config  config.Rabbit
}

Rabbit stores references to RabbitMQ connections, channels, queues, and config

func NewRabbit

func NewRabbit(config config.Rabbit) (*Rabbit, error)

NewRabbit creates and returns a new Rabbit struct

func (*Rabbit) Consume

func (r *Rabbit) Consume() (<-chan amqp.Delivery, error)

Consume starts a worker that returns a channel from the queue to read from

func (*Rabbit) Destroy

func (r *Rabbit) Destroy()

Destroy ends the rabbitmq connection

func (*Rabbit) Produce

func (r *Rabbit) Produce(request interface{}) error

Produce adds a message to the queue based on a send request

type RabbitI

type RabbitI interface {
	Produce(interface{}) error
	Consume() (<-chan amqp.Delivery, error)
	Destroy()
}

RabbitI describes the gateway for interacting with RabbitMQ

type S3

type S3 interface {
	Upload(bucket, name string, body io.Reader) (string, error)
}

S3 defines an interface that will upload an image and return the image's url

func NewS3

func NewS3(config config.S3) S3

NewS3 creates and returns an S3 gateway. If config is not empty, it attempts to set

the environment variables, otherwise it relies on AWS_* env variables to be set

type SQL

type SQL interface {
	Modify(string, ...interface{}) error
	Select(string, ...interface{}) (*sql.Rows, error)
	Destroy()
}

SQL describes the implementation of any sql gateway

type Sendgrid

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

Sendgrid implements SendgridI for a given sendgrid config

func (*Sendgrid) SendEmail

func (s *Sendgrid) SendEmail(target string, subject string, text string) error

SendEmail sends an email through sendgrid with the given target email

type SendgridI

type SendgridI interface {
	SendEmail(string, string, string) error
}

SendgridI is the interface for sendgrid gateways

func NewSendgrid

func NewSendgrid(config config.Sendgrid) SendgridI

NewSendgrid returns a pointer to a Sendgrid struct

type ServiceResponse

type ServiceResponse struct {
	Msg     string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Success bool        `json:"success,omitempty"`
}

ServiceResponse is used to unmarshal data from expresso services. It can be used in conjunction with the following methods like this:

data, _ := ServiceGet(url) var c []*models.Content err := json.Unmarshal(data, &c)

Since ServiceGet returns data as a []byte, we can unmarshal it to whatever is needed in the calling method. Here, its []*models.Content

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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