dynamodb

package
v0.0.0-...-6377813 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

package dynamodb implements ServiceDiscovery interface using dynamodb tables.

Index

Constants

View Source
const DefaultAwsRegion = "eu-west-1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DdbTableName string `yaml:"ddb_table_name"`
	AwsAccessKey string `yaml:"aws_access_key"`
	AwsSecretKey string `yaml:"aws_secret_key"`
	AwsRegion    string `yaml:"aws_region"`
}

func (Config) HasError

func (cfg Config) HasError() error

type LocalConfig

type LocalConfig struct {
	DdbTableName string `yaml:"ddb_table_name"`
	Endpoint     string `yaml:"endpoint"`
	AwsRegion    string `yaml:"aws_region"`
}

func (LocalConfig) HasError

func (cfg LocalConfig) HasError() error

type ServiceDiscoveryDynamoDB

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

ServiceDiscoveryDynamoDB holds the details required to implement a ServiceDiscovery using dynamodb TODO: should this be private? name is too long

func New

New will take in the Config provided and attempt to create a connection to DynamoDB. If the cfg does not set the Access and Secret key (if they are the) empty string, it will fall back to the ENV variables and the IAM credentials of the instance (if running in EC2)

func NewDynamoDBLocal

func NewDynamoDBLocal(cfg LocalConfig) (*ServiceDiscoveryDynamoDB, error)

NewDynamoDBLocal uses a local instance of dynamodb running on endpoint

func (*ServiceDiscoveryDynamoDB) ListWorkers

func (svc *ServiceDiscoveryDynamoDB) ListWorkers(service sd.ServiceRole, earliestLastSeen time.Time) ([]*sd.ServiceWorker, error)

func (*ServiceDiscoveryDynamoDB) RegisterWorker

func (svc *ServiceDiscoveryDynamoDB) RegisterWorker(worker sd.ServiceWorker, heartBeat time.Time) error

type ServiceWorkerDdb

type ServiceWorkerDdb struct {
	ServiceId string    `dynamodbav:"serviceId"`
	WorkerId  string    `dynamodbav:"workerId"`
	LastSeen  time.Time `dynamodbav:"last_seen_time,unixtime"`
	Endpoint  string    `dynamodbav:"endpoint"`

	Role        string `dynamodbav:"role"`
	DeployGroup string `dynamodbav:"deploy_group"`
	ServiceName string `dynamodbav:"service_name"`
}

Jump to

Keyboard shortcuts

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