shareddiscovery

package module
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

README

Shared Discovery

A library for shared code in the Discovery Service.

Installation

Usage

Testing

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 and the private key is stored in Secrets Manager.

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 SharedDiscoveryIFace

// setup AWS Session
session := session.New()

// setup DynamoDB
dynamo := dynamodb.New(session)

// define a QueryInput
query := QueryInput{Workspace: "tableName"}

// setup shareddiscovery now
shareddiscovery = New(dynamo)

// call functions
shareddiscovery.GetConfig(context.Background(), "someApiToken", query)
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryInput

type QueryInput struct {
	Environment string
	AppName     string
	Country     string
	Brand       string
	Workspace   string
	QueryString map[string]string
}

QueryInput defines the values used to query dynamo with.

type SharedDiscovery

type SharedDiscovery struct {
	SharedDiscoveryIFace
	DynamodbSvc dynamodbiface.DynamoDBAPI
}

SharedDiscovery is a custom service object for interacting with the global config

func New

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) GetConfig

func (service SharedDiscovery) GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error)

GetConfig uses the provided `APIToken` to get the correct configuration from the specified `tableName`.

type SharedDiscoveryIFace

type SharedDiscoveryIFace interface {
	GetConfig(ctx context.Context, apiToken string, query QueryInput) (map[string]interface{}, error)
}

SharedDiscoveryIFace describes what is required for building a SharedDiscovery implementation.

Directories

Path Synopsis
mocks
mock_dynamodbiface
Package mock_dynamodbiface is a generated GoMock package.
Package mock_dynamodbiface is a generated GoMock package.

Jump to

Keyboard shortcuts

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