results

package
v0.0.0-...-9581e64 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

There are two hot tables in DynamoDB for CheckResults and CheckResponses

named check_results and check_responses respectively.

Querying check_results is generally done by querying one of the two Global Secondary Indexes (GSIs). The first GSI is on check_id, and the second is on customer_id. Querying GSI will return tuples of (check_id, result_id) and (customer_id, result_id) items respectively.

The partition key for check_results, "result_id" is a combination of <check_id>:<bastion_id>. This should allow relatively even partitioning of the checks.

Examples:

To get results for a single check, you would execute the query:

{
    "TableName": "check_results",
    "IndexName": "check_id-index",
    "KeyConditionExpression": "check_id = :check_id"
}

You would then need to execute a BatchGetItem request to get all of the result objects at once.

TODO: we should cache the responses from the first query, because those won't change very often. The response from the second request will probably never be worth caching.

To get all results for a customer, you would execute the query:

{
    "TableName": "check_results",
    "IndexName": "customer_id-index",
    "KeyConditionExpression": "customer_id = :customer_id"
}

Similarly, you would then follow it up with a BatchGetItem request for every result in the query result set.

CheckResponses are indexed by a "response_id" which is the combination <check_id>:<bastion_id>:<target_id>. To get the responses associated with a CheckResult, you first query check_results. The result returned will include a "responses" field that will be an array of string values that are the response_ids of the associated responses. You can then issue a BatchGetItem request on check_responses to get each of those.

Index

Constants

View Source
const (
	CheckResultTableName           = "check_results"
	CheckResultCheckIdIndexName    = "check_id-index"
	CheckResultCustomerIdIndexName = "customer_id-index"
	CheckResponseTableName         = "check_responses"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamoStore

type DynamoStore struct {
	DynaClient *dynamodb.DynamoDB
}

func (*DynamoStore) GetResultByCheckId

func (s *DynamoStore) GetResultByCheckId(bastionId, checkId string) (result *schema.CheckResult, err error)

func (*DynamoStore) PutResult

func (s *DynamoStore) PutResult(result *schema.CheckResult) error

type S3Store

type S3Store struct {
	BucketName string
	S3Client   *s3.S3
}

S3Store stores CheckResult objects in S3 by ResultId (check_id:bastion_id).

func (*S3Store) GetCheckSnapshot

func (s *S3Store) GetCheckSnapshot(transitionId int64, checkId string) (check *schema.Check, err error)

func (*S3Store) GetResultByCheckId

func (s *S3Store) GetResultByCheckId(bastionId, checkId string) (result *schema.CheckResult, err error)

GetResultByCheckId gets the latest CheckResult for a Check from persistent storage.

func (*S3Store) PutCheckSnapshot

func (s *S3Store) PutCheckSnapshot(transitionId int64, check *schema.Check) error

func (*S3Store) PutResult

func (s *S3Store) PutResult(result *schema.CheckResult) error

PutResult puts a CheckResult to persistent storage.

type Store

type Store interface {
	GetResultByCheckId(bastionId, checkId string) (*schema.CheckResult, error)
	PutResult(result *schema.CheckResult) error
	GetCheckSnapshot(transitionId int64, checkId string) (*schema.Check, error)
	PutCheckSnapshot(transitionId int64, check *schema.Check) error
}

Store is used to store CheckResults and snapshots of checks with results.

Jump to

Keyboard shortcuts

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