store

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TypeMemory indicates the in-memory selection.
	TypeMemory = "MEMORY"
	// TypeDynamo indicates the AWS DynamoDB selection.
	TypeDynamo = "DYNAMODB"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Component

type Component struct {
	Memory *MemoryComponent
	Dynamo *DynamoComponent
}

Component is the top level aggregate of all store components.

func NewComponent

func NewComponent() *Component

NewComponent constructs a default component.

func (*Component) New

func (c *Component) New(ctx context.Context, conf *Config) (domain.Store, error)

New generates a store from the configuration.

func (*Component) Settings

func (c *Component) Settings() *Config

Settings returns the default configuration.

type Config

type Config struct {
	Type   string `description:"The type of data store to use for results tracking."`
	Memory *MemoryConfig
	Dynamo *DynamoConfig
}

Config is the top level aggregate of all store implemenations.

func (*Config) Name

func (*Config) Name() string

Name of the configuration root.

type DynamoComponent

type DynamoComponent struct {
	DynamoDB *awscmp.DynamoDBComponent
}

DynamoComponent implements the component interface for the in-memory option.

func NewDynamoComponent

func NewDynamoComponent() *DynamoComponent

NewDynamoComponent constructs a default DynamoComponent.

func (*DynamoComponent) New

New constructs the component.

func (*DynamoComponent) Settings

func (c *DynamoComponent) Settings() *DynamoConfig

Settings returns the default configuration.

type DynamoConf

type DynamoConf struct {
	*awscmp.DynamoDBConfig
}

DynamoConf wraps the original config to add a name.

func (*DynamoConf) Name

func (*DynamoConf) Name() string

Name of the configuration root.

type DynamoConfig

type DynamoConfig struct {
	TableName    string `description:"The name of the DynamoDB table to use."`
	PartitionKey string `description:"Name of the table partition key."`
	TTLKey       string `description:"Name of the TTL key."`
	AWS          *DynamoConf
}

DynamoConfig contains all settings for the in-memory component.

func (*DynamoConfig) Name

func (*DynamoConfig) Name() string

Name of the configuration root.

type DynamoDB

type DynamoDB struct {
	Client           dynamodbiface.DynamoDBAPI
	TableName        string
	PartitionKeyName string
	TTLKeyName       string
}

DynamoDB implements store using AWS DynamoDB.

func (*DynamoDB) Load

func (s *DynamoDB) Load(ctx context.Context, identifier string) ([]domain.Finding, error)

Load the value of the identifier.

func (*DynamoDB) Mark

func (s *DynamoDB) Mark(ctx context.Context, identifier string) error

Mark the identifier as in-progress.

func (*DynamoDB) Set

func (s *DynamoDB) Set(ctx context.Context, identifier string, findings []domain.Finding) error

Set the value of the identifier.

type Memory

type Memory struct {
	Map sync.Map
}

Memory is an in-memory implementation of the store. This may be used for cases where only one instance of the service is running but is not compatible with multi-node deployments.

Note: This implementation does not clean up after itself and will grow unbounded over time. This is not for production use.

func (*Memory) Load

func (s *Memory) Load(ctx context.Context, identifier string) ([]domain.Finding, error)

Load the value of the identifier.

func (*Memory) Mark

func (s *Memory) Mark(ctx context.Context, identifier string) error

Mark the identifier as in-progress.

func (*Memory) Set

func (s *Memory) Set(ctx context.Context, identifier string, findings []domain.Finding) error

Set the value of the identifier.

type MemoryComponent

type MemoryComponent struct{}

MemoryComponent implements the component interface for the in-memory option.

func NewMemoryComponent

func NewMemoryComponent() *MemoryComponent

NewMemoryComponent constructs a default MemoryComponent.

func (*MemoryComponent) New

New constructs the component.

func (*MemoryComponent) Settings

func (*MemoryComponent) Settings() *MemoryConfig

Settings returns the default configuration.

type MemoryConfig

type MemoryConfig struct{}

MemoryConfig contains all settings for the in-memory component.

func (*MemoryConfig) Name

func (*MemoryConfig) Name() string

Name of the configuration root.

Jump to

Keyboard shortcuts

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