Documentation ¶
Overview ¶
SharedDiscovery is a shared library that supports getting data from the discovery dynamodb tables based on several criteria, including:
- APIToken
- Country
- Workspace (tablename)
Admin Capabilities ¶
This library also supports the idea of admin calls that can get any token needed. This is done using HMAC. For out purposes, the private key is stored in Secrets Manager under the name of the brand/environment.
Example ¶
Typical usage is to setup a variable with the interface type and initialize that variable in your modules init function using the New() function provided
var shareddiscovery IFace // setup AWS Session session, _ := session.NewSession() // setup DynamoDB dynamo := dynamodb.New(session) // define a QueryInput query := QueryInput{Workspace: "tableName"} // setup shareddiscovery now shareddiscovery = New(dynamo) // call functions _, err := shareddiscovery.GetConfig(context.Background(), "someApiToken", query) if err != nil { // deal with the error }
Output:
Index ¶
- Variables
- type IFace
- type QueryInput
- type Result
- type SharedDiscovery
- func (service SharedDiscovery) AdminGetAPIToken(ctx context.Context, secretKey string, query QueryInput) (string, error)
- func (service SharedDiscovery) GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error)
- func (service SharedDiscovery) GetValidation(ctx context.Context, query QueryInput) (bool, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var LambdaTimer = 9 * time.Second
Functions ¶
This section is empty.
Types ¶
type IFace ¶
type IFace interface { GetValidation(ctx context.Context, query QueryInput) (bool, error) GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error) AdminGetAPIToken(ctx context.Context, secretKey string, query QueryInput) (string, error) }
IFace describes what is required for building a SharedDiscovery implementation.
type QueryInput ¶
type QueryInput struct { AppName string Brand string Country string Environment string Signature string QueryString map[string]string Workspace string }
QueryInput defines the values used to query dynamo with.
type SharedDiscovery ¶
type SharedDiscovery struct {}
SharedDiscovery is a custom service object for interacting with the global config
func New ¶
func New(dynamodb dynamodbiface.DynamoDBAPI) SharedDiscovery
New is a constructor that takes a preconfigured dynamodbiface and returns an implementation of SharedDiscoveryIFace Use this in your init function after creating your aws session and initializing dynamo.
func (SharedDiscovery) AdminGetAPIToken ¶
func (service SharedDiscovery) AdminGetAPIToken(ctx context.Context, secretKey string, query QueryInput) (string, error)
func (SharedDiscovery) GetConfig ¶
func (service SharedDiscovery) GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error)
func (SharedDiscovery) GetValidation ¶ added in v0.0.2
func (service SharedDiscovery) GetValidation(ctx context.Context, query QueryInput) (bool, error)
Directories ¶
Path | Synopsis |
---|---|
mocks
|
|
mock_dynamodbiface
Package mock_dynamodbiface is a generated GoMock package.
|
Package mock_dynamodbiface is a generated GoMock package. |