httpd

package
v1.0.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2016 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBindAddress = ":8086"

DefaultBindAddress is the default address to bind to.

View Source
const (
	// DefaultChunkSize specifies the maximum number of points that will
	// be read before sending results back to the engine.
	//
	// This has no relation to the number of bytes that are returned.
	DefaultChunkSize = 10000
)

Variables

This section is empty.

Functions

func LimitListener added in v1.0.0

func LimitListener(l net.Listener, n int) net.Listener

LimitListener returns a Listener that accepts at most n simultaneous connections from the provided Listener and will drop extra connections.

func MarshalJSON

func MarshalJSON(v interface{}, pretty bool) []byte

MarshalJSON will marshal v to JSON. Pretty prints if pretty is true.

Types

type AuthenticationMethod added in v1.0.0

type AuthenticationMethod int

AuthenticationMethod defines the type of authentication used.

const (
	UserAuthentication AuthenticationMethod = iota
	BearerAuthentication
)

Supported authentication methods.

type Config

type Config struct {
	Enabled            bool   `toml:"enabled"`
	BindAddress        string `toml:"bind-address"`
	AuthEnabled        bool   `toml:"auth-enabled"`
	LogEnabled         bool   `toml:"log-enabled"`
	WriteTracing       bool   `toml:"write-tracing"`
	PprofEnabled       bool   `toml:"pprof-enabled"`
	HTTPSEnabled       bool   `toml:"https-enabled"`
	HTTPSCertificate   string `toml:"https-certificate"`
	HTTPSPrivateKey    string `toml:"https-private-key"`
	MaxRowLimit        int    `toml:"max-row-limit"`
	MaxConnectionLimit int    `toml:"max-connection-limit"`
	SharedSecret       string `toml:"shared-secret"`
}

Config represents a configuration for a HTTP service.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with default settings.

type Handler

type Handler struct {
	Version string

	MetaClient interface {
		Database(name string) *meta.DatabaseInfo
		Authenticate(username, password string) (ui *meta.UserInfo, err error)
		Users() []meta.UserInfo
		User(username string) (*meta.UserInfo, error)
	}

	QueryAuthorizer interface {
		AuthorizeQuery(u *meta.UserInfo, query *influxql.Query, database string) error
	}

	WriteAuthorizer interface {
		AuthorizeWrite(username, database string) error
	}

	QueryExecutor *influxql.QueryExecutor

	PointsWriter interface {
		WritePoints(database, retentionPolicy string, consistencyLevel models.ConsistencyLevel, points []models.Point) error
	}

	ContinuousQuerier continuous_querier.ContinuousQuerier

	Config *Config
	Logger *log.Logger
	// contains filtered or unexported fields
}

Handler represents an HTTP handler for the InfluxDB server.

func NewHandler

func NewHandler(c Config, statMap *expvar.Map) *Handler

NewHandler returns a new instance of handler with routes.

func (*Handler) AddRoutes added in v0.12.0

func (h *Handler) AddRoutes(routes ...Route)

AddRoutes sets the provided routes on the handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP responds to HTTP request to the handler.

type Response

type Response struct {
	Results []*influxql.Result
	Err     error
}

Response represents a list of statement results.

func (*Response) Error

func (r *Response) Error() error

Error returns the first error from any statement. Returns nil if no errors occurred on any statements.

func (Response) MarshalJSON

func (r Response) MarshalJSON() ([]byte, error)

MarshalJSON encodes a Response struct into JSON.

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the data into the Response struct

type Route added in v0.12.0

type Route struct {
	Name           string
	Method         string
	Pattern        string
	Gzipped        bool
	LoggingEnabled bool
	HandlerFunc    interface{}
}

Route specifies how to handle a HTTP verb for a given endpoint.

type Service

type Service struct {
	Handler *Handler

	Logger *log.Logger
	// contains filtered or unexported fields
}

Service manages the listener and handler for an HTTP endpoint.

func NewService

func NewService(c Config) *Service

NewService returns a new instance of Service.

func (*Service) Addr

func (s *Service) Addr() net.Addr

Addr returns the listener's address. Returns nil if listener is closed.

func (*Service) Close

func (s *Service) Close() error

Close closes the underlying listener.

func (*Service) Err

func (s *Service) Err() <-chan error

Err returns a channel for fatal errors that occur on the listener.

func (*Service) Open

func (s *Service) Open() error

Open starts the service

func (*Service) SetLogOutput added in v0.13.0

func (s *Service) SetLogOutput(w io.Writer)

SetLogOutput sets the writer to which all logs are written. It must not be called after Open is called.

Jump to

Keyboard shortcuts

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