routing

package
Version: v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("record not found")

ErrNotFound will be returned when a record we are looking for is not found in the db

Functions

func SetDefaultRepository

func SetDefaultRepository(r Repository)

Sets the default repository for resolving. Can be used to override for mocking/testing purposes

Types

type Record

type Record struct {
	Hash      string `dynamodbav:"hash"`
	Routing   string `dynamodbav:"routing"`
	PublicKey string `dynamodbav:"public_key"`
	Serial    uint64 `dynamodbav:"sn"`
}

Record holds a DynamoDB record

type Repository

type Repository interface {
	Get(hash string) (*ResolveInfoType, error)
	Create(hash, routing, publicKey string) (bool, error)
	Update(info *ResolveInfoType, routing, publicKey string) (bool, error)
	Delete(hash string) (bool, error)
}

Repository to resolve records

func GetResolveRepository

func GetResolveRepository() Repository

GetResolveRepository returns a new repository based on DynamoDB

func NewBoltResolver

func NewBoltResolver() Repository

NewBoltResolver returns a new resolver based on BoltDB

func NewDynamoDBResolver

func NewDynamoDBResolver(client *dynamodb.DynamoDB, tableName string) Repository

NewDynamoDBResolver returns a new resolver based on DynamoDB

type ResolveInfoType

type ResolveInfoType struct {
	Hash    string
	Routing string
	PubKey  string
	Serial  uint64
}

ResolveInfoType returns information found in the resolver repository

type SqliteDbResolver

type SqliteDbResolver struct {
	TimeNow time.Time
	// contains filtered or unexported fields
}

func NewSqliteResolver

func NewSqliteResolver(dsn string) *SqliteDbResolver

NewDynamoDBResolver returns a new resolver based on DynamoDB

func (*SqliteDbResolver) Create

func (r *SqliteDbResolver) Create(hash, routing, publicKey string) (bool, error)

func (*SqliteDbResolver) Delete

func (r *SqliteDbResolver) Delete(hash string) (bool, error)

func (*SqliteDbResolver) Get

func (r *SqliteDbResolver) Get(hash string) (*ResolveInfoType, error)

func (*SqliteDbResolver) Update

func (r *SqliteDbResolver) Update(info *ResolveInfoType, routing, publicKey string) (bool, error)

Jump to

Keyboard shortcuts

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