handlers

package
v0.0.0-...-ad801e6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HealthPath = "/health"
	WritePath  = "/write"
	QueryPath  = "/query"
)

A list of HTTP endpoints. TODO(xichen): API versioning.

Variables

This section is empty.

Functions

func RegisterService

func RegisterService(mux *http.ServeMux, s Service)

RegisterService registers handler service.

Types

type IDFn

type IDFn func(value *value.Value) ([]byte, error)

IDFn determines the ID of a JSON document.

type NamespaceFn

type NamespaceFn func(value *value.Value) ([]byte, error)

NamespaceFn determines the namespace a JSON document belongs to.

type Options

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

Options provide a set of options for service handlers.

func NewOptions

func NewOptions() *Options

NewOptions create a new set of options.

func (*Options) ClockOptions

func (o *Options) ClockOptions() clock.Options

ClockOptions returns the clock options.

func (*Options) IDFn

func (o *Options) IDFn() IDFn

IDFn returns the ID function.

func (*Options) InstrumentOptions

func (o *Options) InstrumentOptions() instrument.Options

InstrumentOptions returns the instrument options.

func (*Options) NamespaceFn

func (o *Options) NamespaceFn() NamespaceFn

NamespaceFn returns the ID function.

func (*Options) ParserPool

func (o *Options) ParserPool() *json.ParserPool

ParserPool returns the pool for JSON parsers.

func (*Options) ReadTimeout

func (o *Options) ReadTimeout() time.Duration

ReadTimeout returns the timeout for a read request.

func (*Options) SetClockOptions

func (o *Options) SetClockOptions(v clock.Options) *Options

SetClockOptions sets the clock options.

func (*Options) SetIDFn

func (o *Options) SetIDFn(value IDFn) *Options

SetIDFn sets the ID function.

func (*Options) SetInstrumentOptions

func (o *Options) SetInstrumentOptions(v instrument.Options) *Options

SetInstrumentOptions sets the instrument options.

func (*Options) SetNamespaceFn

func (o *Options) SetNamespaceFn(value NamespaceFn) *Options

SetNamespaceFn sets the namespace function.

func (*Options) SetParserPool

func (o *Options) SetParserPool(value *json.ParserPool) *Options

SetParserPool sets the pool for JSON parsers.

func (*Options) SetReadTimeout

func (o *Options) SetReadTimeout(value time.Duration) *Options

SetReadTimeout sets the timeout for a read request.

func (*Options) SetTimeNanosFn

func (o *Options) SetTimeNanosFn(value TimeNanosFn) *Options

SetTimeNanosFn sets the timestamp function.

func (*Options) SetWriteTimeout

func (o *Options) SetWriteTimeout(value time.Duration) *Options

SetWriteTimeout sets the timeout for a write request.

func (*Options) TimeNanosFn

func (o *Options) TimeNanosFn() TimeNanosFn

TimeNanosFn returns the timestamp function.

func (*Options) WriteTimeout

func (o *Options) WriteTimeout() time.Duration

WriteTimeout returns the timeout for a write request.

type Response

type Response struct {
	State string `json:"state,omitempty"`
	Error string `json:"error,omitempty"`
}

Response is an HTTP response.

func NewResponse

func NewResponse() Response

NewResponse creates a new empty response.

type Service

type Service interface {
	// Health returns service health.
	Health(w http.ResponseWriter, r *http.Request)

	// Write writes one or more JSON events. Documents are delimited with newline.
	Write(w http.ResponseWriter, r *http.Request)

	// Query performs an document query.
	Query(w http.ResponseWriter, r *http.Request)
}

Service provides handlers for serving HTTP requests.

func NewService

func NewService(db storage.Database, opts *Options) Service

NewService creates a new service.

type TimeNanosFn

type TimeNanosFn func(value *value.Value) (int64, error)

TimeNanosFn determines the timestamp of a JSON document in nanoseconds.

Jump to

Keyboard shortcuts

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