api

package
v0.0.0-...-b09f343 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: BSD-3-Clause, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DBRoleARN specifies the IAM Role to assume
	DBRoleARN = ""
	// AWSConsumedCapacityIndex specifies DynamoDB return aggregate RCU usage
	AWSConsumedCapacityIndex = dynamodb.ReturnConsumedCapacityIndexes
	// AWSItemCollection specifies the metric types returned
	AWSItemCollection = dynamodb.ReturnItemCollectionMetricsSize
)

Functions

This section is empty.

Types

type API

type API struct {
	Table config.Tables
	// contains filtered or unexported fields
}

API manages client connections with outside services

func New

func New(opts ...Opts) (*API, error)

New constructs and returns an api client for client communications

func WithSession

func WithSession(a *API) (*API, error)

WithSession inserts a given session into API

func (*API) Get

func (a *API) Get(table, attr string, last *types.Record) *types.MultiQuoteRes

Get fetches a paginated response of quotes related to attribute

func (*API) Put

func (a *API) Put(opts ...PutOpt) error

Put enters a new quote into DynamoDB

func (*API) PutWithAuthor

func (a *API) PutWithAuthor(author *types.Record) PutOpt

PutWithAuthor add author to transaction

func (*API) PutWithQuote

func (a *API) PutWithQuote(quote *types.Quote) PutOpt

PutWithQuote adds quote to transaction

func (*API) PutWithTopics

func (a *API) PutWithTopics(topics []*types.Record) PutOpt

PutWithTopics adds topics to the transaction

func (*API) Random

func (a *API) Random() *types.QuoteRes

Random fetches a random quote from the database

type Opts

type Opts func(*API) (*API, error)

Opts is the type signature for optional functions modifying API

func WithDynamoDBService

func WithDynamoDBService(c *config.Config) Opts

WithDynamoDBService initializes the aws dynamodb agent

func WithEC2

func WithEC2(isProd bool) Opts

WithEC2 inits EC2 client if production

func WithPaginationLimit

func WithPaginationLimit(limit int64) Opts

WithPaginationLimit inserts the given pagination limit into DB

func WithTables

func WithTables(t config.Tables) Opts

WithTables inserts the name of the tables into DB

func WithXray

func WithXray(isProd bool) Opts

WithXray inits XRay tracing if production

type PutInput

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

PutInput represents the input of the Put handler

func (*PutInput) WithItem

func (p *PutInput) WithItem(v interface{}, t string) (*PutInput, error)

WithItem adds an item to to the transaction

type PutOpt

type PutOpt func(*PutInput) (*PutInput, error)

PutOpt represents the configuration for PutInput

Jump to

Keyboard shortcuts

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