multitenant

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2016 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNotFound is returned by ConsulClient.Get
	ErrNotFound = fmt.Errorf("Not found")
)
View Source
var ErrUserIDNotFound = fmt.Errorf("User ID not found")

ErrUserIDNotFound should be returned by a UserIDer when it fails to ID the user for a request.

Functions

func NewConsulPipeRouter

func NewConsulPipeRouter(client ConsulClient, prefix, advertise string, userIDer UserIDer) app.PipeRouter

NewConsulPipeRouter returns a new consul based router

func NewSQSControlRouter

func NewSQSControlRouter(config *aws.Config, userIDer UserIDer, prefix string) app.ControlRouter

NewSQSControlRouter the harbinger of death

func NoopUserIDer

func NoopUserIDer(context.Context) (string, error)

NoopUserIDer always returns the empty user ID.

Types

type AWSCollector added in v0.16.1

type AWSCollector interface {
	app.Collector
	CreateTables() error
}

AWSCollector is a Collector which can also CreateTables

func NewAWSCollector added in v0.16.1

func NewAWSCollector(config AWSCollectorConfig) (AWSCollector, error)

NewAWSCollector the elastic reaper of souls https://github.com/aws/aws-sdk-go/wiki/common-examples

type AWSCollectorConfig added in v0.16.1

type AWSCollectorConfig struct {
	UserIDer       UserIDer
	DynamoDBConfig *aws.Config
	DynamoTable    string
	S3Store        *S3Store
	NatsHost       string
	MemcacheClient *MemcacheClient
	Window         time.Duration
}

AWSCollectorConfig has everything we need to make an AWS collector.

type CASCallback

type CASCallback func(in interface{}) (out interface{}, retry bool, err error)

CASCallback is the type of the callback to CAS. If err is nil, out must be non-nil.

type ConsulClient

type ConsulClient interface {
	Get(key string, out interface{}) error
	CAS(key string, out interface{}, f CASCallback) error
	WatchPrefix(prefix string, out interface{}, done chan struct{}, f func(string, interface{}) bool)
}

ConsulClient is a high-level client for Consul, that exposes operations such as CAS and Watch which take callbacks. It also deals with serialisation.

func NewConsulClient

func NewConsulClient(addr string) (ConsulClient, error)

NewConsulClient returns a new ConsulClient

type MemcacheClient added in v0.16.1

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

MemcacheClient is a memcache client that gets its server list from SRV records, and periodically updates that ServerList.

func NewMemcacheClient added in v0.16.1

func NewMemcacheClient(config MemcacheConfig) *MemcacheClient

NewMemcacheClient creates a new MemcacheClient that gets its server list from SRV and updates the server list on a regular basis.

func (*MemcacheClient) FetchReports added in v0.16.1

func (c *MemcacheClient) FetchReports(keys []string) (map[string]report.Report, []string, error)

FetchReports gets reports from memcache.

func (*MemcacheClient) Stop added in v0.16.1

func (c *MemcacheClient) Stop()

Stop the memcache client.

func (*MemcacheClient) StoreBytes added in v0.16.1

func (c *MemcacheClient) StoreBytes(key string, content []byte) error

StoreBytes stores a report, expecting the report to be serialized already.

type MemcacheConfig added in v0.16.1

type MemcacheConfig struct {
	Host           string
	Service        string
	Timeout        time.Duration
	UpdateInterval time.Duration
	Expiration     time.Duration
}

MemcacheConfig defines how a MemcacheClient should be constructed.

type ReportStore added in v0.16.1

type ReportStore interface {
	FetchReports([]string) (map[string]report.Report, []string, error)
}

ReportStore is a thing that we can get reports from.

type S3Store added in v0.16.1

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

S3Store is an S3 client that stores and retrieves Reports.

func NewS3Client added in v0.16.1

func NewS3Client(config *aws.Config, bucketName string) S3Store

NewS3Client creates a new S3 client.

func (*S3Store) FetchReports added in v0.16.1

func (store *S3Store) FetchReports(keys []string) (map[string]report.Report, []string, error)

FetchReports fetches multiple reports in parallel from S3.

func (*S3Store) StoreBytes added in v0.16.1

func (store *S3Store) StoreBytes(key string, content []byte) error

StoreBytes stores a report in S3, expecting the report to be serialized already.

type UserIDer

type UserIDer func(context.Context) (string, error)

UserIDer identifies users given a request context.

func UserIDHeader

func UserIDHeader(headerName string) UserIDer

UserIDHeader returns a UserIDer which a header by the supplied key.

Jump to

Keyboard shortcuts

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