httpd

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0, MIT Imports: 59 Imported by: 0

Documentation

Index

Constants

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

	MaxChunkSize = DefaultChunkSize * 50

	DefaultInnerChunkSize = 1024

	MaxInnerChunkSize = 4096

	DefaultDebugRequestsInterval = 10 * time.Second

	MaxDebugRequestsInterval = 6 * time.Hour
)

Variables

View Source
var (
	// ErrBearerAuthDisabled is returned when client specifies bearer auth in
	// a request but bearer auth is disabled.
	ErrBearerAuthDisabled = errors.New("bearer auth disabld")
)

Functions

func GetGzipReader

func GetGzipReader(r io.Reader) (*gzip.Reader, error)

func Points2Rows

func Points2Rows(points []models.Point) ([]influx.Row, error)

func PutGzipReader

func PutGzipReader(zr *gzip.Reader)

PutGzipReader returns back gzip reader obtained via GetGzipReader.

func ReadRequestToInfluxQuery

func ReadRequestToInfluxQuery(req *prompb.ReadRequest) (string, error)

func TagsConverterRemoveInfluxSystemTag

func TagsConverterRemoveInfluxSystemTag(tags map[string]string) models.Tags

Types

type AuthenticationMethod

type AuthenticationMethod int

AuthenticationMethod defines the type of authentication used.

const (
	// Authenticate using basic authentication.
	UserAuthentication AuthenticationMethod = iota

	// Authenticate with jwt.
	BearerAuthentication
)

Supported authentication methods.

type Handler

type Handler struct {
	Version   string
	BuildType string

	MetaClient interface {
		Database(name string) (*meta2.DatabaseInfo, error)
		Authenticate(username, password string) (ui meta2.User, err error)
		User(username string) (meta2.User, error)
		AdminUserExists() bool
		DataNodes() ([]meta2.DataNode, error)
		ShowShards() models.Rows
	}

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

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

	ExtSysCtrl interface {
		SendSysCtrlOnNode(nodID uint64, req netstorage.SysCtrlRequest) (map[string]string, error)
	}

	QueryExecutor *query2.Executor

	Monitor interface {
	}

	PointsWriter interface {
		WritePointRows(database, retentionPolicy string, points []influx.Row) error
	}

	Config    *config.Config
	Logger    *logger.Logger
	CLFLogger *zap.Logger
	// contains filtered or unexported fields
}

Handler represents an HTTP handler for the InfluxDB server.

func NewHandler

func NewHandler(c config.Config) *Handler

NewHandler returns a new instance of handler with routes.

func (*Handler) AddRoutes

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

AddRoutes sets the provided routes on the handler.

func (*Handler) Close

func (h *Handler) Close()

func (*Handler) Open

func (h *Handler) Open()

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 []*query.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

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 {
	Ln []net.Listener

	Handler *Handler

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

Service manages the listener and handler for an HTTP endpoint.

func NewService

func NewService(c config.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. test func, so return 0 index addr

func (*Service) BoundHTTPAddr

func (s *Service) BoundHTTPAddr() string

BoundHTTPAddr returns the string version of the address that the HTTP server is listening on. This is useful if you start an ephemeral server in test with bind address localhost:0. test func, so return 0 index addr

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) Openlistener

func (s *Service) Openlistener(addr string) error

type Throttler

type Throttler struct {

	// Maximum amount of time requests can wait in queue.
	// Must be set before adding middleware.
	EnqueueTimeout time.Duration

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

Throttler represents an HTTP throttler that limits the number of concurrent requests being processed as well as the number of enqueued requests.

func NewThrottler

func NewThrottler(concurrentN, maxEnqueueN int, rateValue int) *Throttler

NewThrottler returns a new instance of Throttler that limits to concurrentN. requests processed at a time and maxEnqueueN requests waiting to be processed.

func (*Throttler) Handler

func (t *Throttler) Handler(h http.Handler) http.Handler

Handler wraps h in a middleware handler that throttles requests.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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