common

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZapLoggerObj *zap.Logger

ZapLoggerObj Global LOgger Object

Functions

func AppendQueryParams added in v1.0.6

func AppendQueryParams(url string, query_params map[string]string) string

func ConfigureDynamoDB

func ConfigureDynamoDB()

ConfigureDynamoDB : For creating dynamodb connection.

func Contains added in v1.0.6

func Contains(arr []string, str string) bool

func Get added in v1.0.8

func Get(url string, queryParams map[string]string, headers http.Header) ([]byte, error)

func GetUTCTimeString added in v1.0.6

func GetUTCTimeString() string

func GetUUID added in v1.0.6

func GetUUID() string

func InterfaceToMap

func InterfaceToMap(request interface{}) map[string]interface{}

InterfaceToMap function converts an interface to map

func IsEmpty added in v1.0.6

func IsEmpty(str string) bool

func Logger

func Logger(inner http.Handler, name string) http.Handler

func LowerFirst added in v1.0.6

func LowerFirst(s string) string

func Post added in v1.0.8

func Post(url string, payload map[string]string, headers http.Header) ([]byte, error)

func PrepareUpdateExpression added in v1.0.6

func PrepareUpdateExpression(request interface{}, keysToExclude []string) map[string]interface{}

func Put added in v1.0.8

func Put(url string, payload map[string]string, headers http.Header) ([]byte, error)

func TransactWriteItems

func TransactWriteItems(transactItems []TransactItem) map[string]interface{}

TransactWriteItems write to dynamodb in a single transaction

func ZapLogger

func ZapLogger() *zap.Logger

ZapLogger logger init

Types

type AWSConfigurations added in v1.0.8

type AWSConfigurations struct {
	Region string
	Tables TableConfigurations
}

AWSConfigurations exported

type Configurations added in v1.0.8

type Configurations struct {
	Server               ServerConfigurations
	AWS                  AWSConfigurations
	Version              string
	FMS                  FMSConfigurations
	HttpTimeoutInSeconds time.Duration
}

Configurations contains all the config data needed for the service

var ConfigurationObj Configurations

ConfigurationObj exported

func ConfigObj added in v1.0.8

func ConfigObj(filePath string) Configurations

ConfigObj exported

type DBService

type DBService struct {
	TableName string
}

DBService : For creating dynamodb connection.

func (DBService) BatchGetItem

func (db DBService) BatchGetItem(keyDetails []map[string]string, items interface{}) error

BatchGetItem gets data from dynamodb (with multiple PK returns multiple records)

func (DBService) BatchWriteItemDelete

func (db DBService) BatchWriteItemDelete(keyDetails []map[string]string, items interface{}) error

BatchWriteItemDelete delete data from dynamodb (with multiple PK delete in single go)

func (DBService) GetItem

func (db DBService) GetItem(keyDetails map[string]string, item interface{}) error

GetItem gets data from dynamodb

func (DBService) PutItem

func (db DBService) PutItem(transactItem TransactItem)

PutItem : Inserts an item into Dynamodb

func (DBService) QueryOnGSI

func (db DBService) QueryOnGSI(keyDetails map[string]string, items interface{}, keyEx string, indexName string) error

QueryOnGSI gets data from dynamodb by querying on GSI

func (DBService) QuerytItem

func (db DBService) QuerytItem(keyDetails map[string]string, items interface{}, keyEx string) error

QuerytItem gets data from dynamodb (only HK returns multiple records)

func (DBService) UpdateItem

func (db DBService) UpdateItem(keyDetails map[string]string,
	itemDetails map[string]string, UpdateExpression string)

UpdateItem : Updates an item in dynamodb

type FMSConfigurations added in v1.0.8

type FMSConfigurations struct {
	URL                   string
	FetchVehiclesEndPoint string
}

type MyDynamo

type MyDynamo struct {
	Db dynamodbiface.DynamoDBAPI
}

MyDynamo : For creating dynamodb connection.

var Dyna *MyDynamo

Dyna - exported

type ServerConfigurations added in v1.0.8

type ServerConfigurations struct {
	Host string
	Port int
}

ServerConfigurations exported

type TableConfigurations added in v1.0.8

type TableConfigurations struct {
	Vehicle TableStructure
}

TableConfigurations exported

var TableDetails TableConfigurations

TableDetails exported

type TableStructure added in v1.0.8

type TableStructure struct {
	TableName string
	HashKey   string
}

TableStructure exported

type TransactItem

type TransactItem struct {
	TransactType              string
	TableName                 string
	KeyDetails                map[string]interface{}
	ItemDetails               interface{}
	ExpressionAttributeValues map[string]interface{}
	UpdateExpression          string
}

TransactItem : For creating TransactItem.

Jump to

Keyboard shortcuts

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