endpoint

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build added in v0.7.0

func Build(mux *http.ServeMux, config *Config, datastores map[string]*datastore.Service,
	hooks []Hook, metrics *gmetric.Service, promReg *prometheus.Registry) error

func IsHelpOption

func IsHelpOption(args []string) bool

IsHelpOption returns true if helper

func NewConfigHandler

func NewConfigHandler(config *Config) http.Handler

func NewProfHandler added in v0.4.0

func NewProfHandler() *memProfHandler

func RunApp deprecated

func RunApp(version string, args []string, wg *sync.WaitGroup)

Deprecated: use RunAppError

func RunAppError added in v0.4.0

func RunAppError(version string, args []string, wg *sync.WaitGroup) error

func RunAppWithConfig deprecated

func RunAppWithConfig(version string, args []string, cp configProvider)

Deprecated: use RunAppErrorWithConfigError

func RunAppWithConfigError added in v0.4.0

func RunAppWithConfigError(version string, args []string, cp configProvider) error

func RunAppWithConfigWaitError added in v0.8.0

func RunAppWithConfigWaitError(version string, args []string, cp configProvider, wg *sync.WaitGroup) error

RunAppWithConfigWaitError is the full options versions. / version is printed if provided in the options. TODO auto-determine version. cp is a function that can provide a configuration file. wg.Done() will be called once, when the server is finished booting up.

Types

type AuthHandler added in v0.7.0

type AuthHandler struct {
	*Config
	// contains filtered or unexported fields
}

func NewAuthHandler added in v0.7.0

func NewAuthHandler(config *Config, handler http.Handler) *AuthHandler

func (*AuthHandler) ServeHTTP added in v0.7.0

func (h *AuthHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type AuthMux added in v0.7.0

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

func NewAuthMux added in v0.7.0

func NewAuthMux(mux *http.ServeMux, config *Config) *AuthMux

func (*AuthMux) Handle added in v0.7.0

func (m *AuthMux) Handle(path string, handler http.Handler)

func (*AuthMux) HandleFunc added in v0.7.0

func (m *AuthMux) HandleFunc(path string, hf func(w http.ResponseWriter, r *http.Request))

type Config

type Config struct {
	config.ModelList      `json:",omitempty" yaml:",inline"`
	sconfig.DatastoreList `json:",omitempty" yaml:",inline"`

	// GlobalBatching provides a default batching configuration if
	// models do not provide their own.
	// If GlobalBatching is provided but a model should not be batching,
	// set BatchWait to < 0.
	GlobalBatching *batchconfig.BatcherConfig `json:",omitempty" yaml:",omitempty"`

	Metrics *econfig.MetricsConfig `json:",omitempty" yaml:",omitempty"`

	Endpoint econfig.Endpoint

	EnableMemProf bool
	EnableCPUProf bool

	AllowedSubnet []string `json:",omitempty" yaml:",omitempty"`
}

Config represents an endpoint config

func NewConfigFromURL

func NewConfigFromURL(ctx context.Context, URL string) (*Config, error)

NewConfigFromURL creates a new config from URL

func (*Config) Init

func (c *Config) Init()

Init initialise config

func (*Config) LoadFromURL

func (c *Config) LoadFromURL(ctx context.Context, URL string, target interface{}) error

func (*Config) Validate

func (c *Config) Validate() error

Validate validates config

type Hook added in v0.8.0

type Hook interface {
	Hook(*config.Model, *service.Service)
}

TODO Refactor out

type Options

type Options struct {
	ConfigURL string `short:"c" long:"cfg" description:"config URI"`
	Version   bool   `short:"v" long:"version" description:"indexer version"`
}

Options represents an option

type Service

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

Service is the primary container for all HTTP based services.

func New

func New(cfg *Config) (*Service, error)

func (*Service) Listen added in v0.6.0

func (s *Service) Listen() (net.Listener, error)

func (*Service) ListenAndServe deprecated

func (s *Service) ListenAndServe() error

Deprecated: use Listen and Serve separately

func (*Service) ListenAndServeTLS deprecated

func (s *Service) ListenAndServeTLS(certFile, keyFile string) error

Deprecated: ListenAndServeTLS start https endpoint on secure port. Practically we terminate encryption via a load balancer.

func (*Service) SelfTest added in v0.6.0

func (s *Service) SelfTest() error

Runs a client side call for each model once.

func (*Service) Serve added in v0.6.0

func (s *Service) Serve(l net.Listener) error

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

Shutdown calls http.(*Server).Shutdown

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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