common

package module
v1.0.1 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

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

func ConfigureDynamoDB

func ConfigureDynamoDB()

ConfigureDynamoDB : For creating dynamodb connection.

func Contains

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

func Get

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

func GetUTCTimeString

func GetUTCTimeString() string

func GetUUID

func GetUUID() string

func InterfaceToMap

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

InterfaceToMap function converts an interface to map

func IsEmpty

func IsEmpty(str string) bool

func Logger

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

func LowerFirst

func LowerFirst(s string) string

func Post

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

func PrepareUpdateExpression

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

func Put

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

type AWSConfigurations struct {
	Region string
	Tables TableConfigurations
}

AWSConfigurations exported

type Configurations

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

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

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

type ServerConfigurations struct {
	Host string
	Port int
}

ServerConfigurations exported

type TableConfigurations

type TableConfigurations struct {
	Vehicle TableStructure
}

TableConfigurations exported

var TableDetails TableConfigurations

TableDetails exported

type TableStructure

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