multitenant

package
Version: v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 40 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, rpcTimeout time.Duration) 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
	MaxTopNodes    int
}

AWSCollectorConfig has everything we need to make an AWS collector.

type BillingEmitter added in v1.3.0

type BillingEmitter struct {
	app.Collector
	BillingEmitterConfig
	// contains filtered or unexported fields
}

BillingEmitter is the billing emitter

func NewBillingEmitter added in v1.3.0

func NewBillingEmitter(upstream app.Collector, billingClient *billing.Client, cfg BillingEmitterConfig) (*BillingEmitter, error)

NewBillingEmitter changes a new billing emitter which emits billing events

func (*BillingEmitter) Add added in v1.3.0

func (e *BillingEmitter) Add(ctx context.Context, rep report.Report, buf []byte) error

Add implements app.Collector

func (*BillingEmitter) Close added in v1.3.0

func (e *BillingEmitter) Close() error

Close shuts down the billing emitter and billing client flushing events.

type BillingEmitterConfig added in v1.3.0

type BillingEmitterConfig struct {
	Enabled         bool
	DefaultInterval time.Duration
	UserIDer        UserIDer
}

BillingEmitterConfig has everything we need to make a billing emitter

func (*BillingEmitterConfig) RegisterFlags added in v1.3.0

func (cfg *BillingEmitterConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags registers the billing emitter flags with the main flag set.

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(ctx context.Context, 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) StoreReportBytes added in v1.0.0

func (c *MemcacheClient) StoreReportBytes(ctx context.Context, key string, rpt []byte) (int, error)

StoreReportBytes stores a report.

type MemcacheConfig added in v0.16.1

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

MemcacheConfig defines how a MemcacheClient should be constructed.

type ReportStore added in v0.16.1

type ReportStore interface {
	FetchReports(context.Context, []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(ctx context.Context, keys []string) (map[string]report.Report, []string, error)

FetchReports fetches multiple reports in parallel from S3.

func (*S3Store) StoreReportBytes added in v1.0.0

func (store *S3Store) StoreReportBytes(ctx context.Context, key string, buf []byte) (int, error)

StoreReportBytes stores a report.

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