server

package
v0.0.0-...-f54f1ef Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCredentialsNotFound = errors.New("credentials not found")

ErrCredentialsNotFound is the error returned by an AuthProvider if credentials corresponding to a given AccessKey cannot be located

Functions

This section is empty.

Types

type AuthProvider

type AuthProvider interface {
	// CredsForKey given an access key, returns the set of corresponding credentials.
	// If no corresponding credentials can be found, an ErrCredentialsNotFound will
	// be returned.
	CredsForKey(string) (*Creds, error)
}

AuthProvider represents the interface for an authentication provider

type AuthProviderStaticFile

type AuthProviderStaticFile struct {
	File string
	// contains filtered or unexported fields
}

AuthProviderStaticFile implements the AuthProvider interface that loads authentication keypairs into memory from a yaml file on disk. If the file is changed on disk, we reload the keys into memory.

func NewAuthProviderStaticFile

func NewAuthProviderStaticFile(ctx context.Context, l *logger.L, filename string, pollInterval time.Duration) (*AuthProviderStaticFile, error)

NewAuthProviderStaticFile creates a new static file auth provider. filename is the path to the file on disk. pollInterval is how frequently to check the file for modification time updates.

func (*AuthProviderStaticFile) CredsForKey

func (a *AuthProviderStaticFile) CredsForKey(accessKey string) (*Creds, error)

CredsForKey given an access key, returns the set of corresponding credentials. If no corresponding credentials can be found, an ErrCredentialsNotFound will be returned.

type Creds

type Creds struct {
	AccessKey string              `yaml:"access_key"`
	SecretKey string              `yaml:"secret_key"`
	Metrics   map[string]struct{} `yaml:"metrics"`
}

Creds represents an api key set and the metrics they are allowed to access

func (*Creds) AllowMetric

func (c *Creds) AllowMetric(name string) bool

AllowMetric returns true if a given metric is allowed for this set of credentials

type MetricWriter

type MetricWriter interface {
	WriteMetric(amproxy.Message) error
}

MetricWriter is the interface for a backend metrics store

type MetricWriterCarbon

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

MetricWriterCarbon will write metrics to a Carbon server. It pools connections.

func NewMetricWriterCarbon

func NewMetricWriterCarbon(l *logger.L, addr string, poolMin, poolMax int) (*MetricWriterCarbon, error)

NewMetricWriterCarbon creates a new MetricWriterCarbon

func (*MetricWriterCarbon) WriteMetric

func (mw *MetricWriterCarbon) WriteMetric(m amproxy.Message) error

WriteMetric writes the given message to the carbon server

type Server

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

Server is an amproxy server. It uses a generic LineProtocolServer to handle the connections, but implements the business logic itself.

func NewServer

func NewServer(l *logger.L, skew time.Duration, authProvider AuthProvider, mw MetricWriter) *Server

NewServer creates a new Server

func (*Server) ProcessLine

func (s *Server) ProcessLine(line string)

Jump to

Keyboard shortcuts

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