http

package
v0.39.2 Latest Latest
Warning

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

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

Documentation

Overview

Package http implements the HTTP service for Flow.

Index

Constants

View Source
const ServiceName = "http"

ServiceName defines the name used for the HTTP service.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arguments added in v0.37.0

type Arguments struct {
	TLS *TLSArguments `river:"tls,block,optional"`
}

Arguments holds runtime settings for the HTTP service.

type ClientAuth added in v0.37.0

type ClientAuth tls.ClientAuthType

ClientAuth configures the type of TLS client authentication to use.

func (ClientAuth) MarshalText added in v0.37.0

func (c ClientAuth) MarshalText() ([]byte, error)

MarshalText marshals the ID of a client auth type to its name.

func (*ClientAuth) UnmarshalText added in v0.37.0

func (c *ClientAuth) UnmarshalText(text []byte) error

UnmarshalText unmarshals the name of a client auth type to its ID.

type Component added in v0.36.0

type Component interface {
	component.Component

	// Handler should return a valid HTTP handler for the component.
	// All requests to the component will have the path trimmed such that the component is at the root.
	// For example, f a request is made to `/component/{id}/metrics`, the component
	// will receive a request to just `/metrics`.
	Handler() http.Handler
}

Component is a Flow component which also contains a custom HTTP handler.

type Data

type Data struct {
	// Address that the HTTP service is configured to listen on.
	HTTPListenAddr string

	// Address that the HTTP service is configured to listen on for in-memory
	// traffic when [DialFunc] is used to establish a connection.
	MemoryListenAddr string

	// BaseHTTPPath is the base path where component HTTP routes are exposed.
	BaseHTTPPath string

	// DialFunc is a function which establishes in-memory network connection when
	// address is MemoryListenAddr. If address is not MemoryListenAddr, DialFunc
	// establishes an outbound network connection.
	DialFunc func(ctx context.Context, network, address string) (net.Conn, error)
}

Data includes information associated with the HTTP service.

func (Data) HTTPPathForComponent added in v0.36.0

func (d Data) HTTPPathForComponent(componentID string) string

HTTPPathForComponent returns the full HTTP path for a given global component ID.

type Options

type Options struct {
	Logger   log.Logger           // Where to send logs.
	Tracer   trace.TracerProvider // Where to send traces.
	Gatherer prometheus.Gatherer  // Where to collect metrics from.

	ReadyFunc  func() bool
	ReloadFunc func() (*flow.Source, error)

	HTTPListenAddr   string // Address to listen for HTTP traffic on.
	MemoryListenAddr string // Address to accept in-memory traffic on.
	EnablePProf      bool   // Whether pprof endpoints should be exposed.
}

Options are used to configure the HTTP service. Options are constant for the lifetime of the HTTP service.

type Service

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

func New

func New(opts Options) *Service

New returns a new, unstarted instance of the HTTP service.

func (*Service) Data

func (s *Service) Data() any

Data returns an instance of Data. Calls to Data are cachable by the caller.

Data must only be called after parsing command-line flags.

func (*Service) Definition

func (s *Service) Definition() service.Definition

Definition returns the definition of the HTTP service.

func (*Service) Run

func (s *Service) Run(ctx context.Context, host service.Host) error

Run starts the HTTP service. It will run until the provided context is canceled or there is a fatal error.

func (*Service) Update

func (s *Service) Update(newConfig any) error

Update implements service.Service and applies settings.

type ServiceHandler added in v0.36.0

type ServiceHandler interface {
	service.Service

	// ServiceHandler returns the base route and HTTP handlers to register for
	// the provided service.
	//
	// This method is only called for services that declare a dependency on
	// the http service.
	//
	// The http service prioritizes longer base routes. Given two base routes of
	// /foo and /foo/bar, an HTTP URL of /foo/bar/baz will be routed to the
	// longer base route (/foo/bar).
	ServiceHandler(host service.Host) (base string, handler http.Handler)
}

ServiceHandler is a Service which exposes custom HTTP handlers.

type TLSArguments added in v0.37.0

type TLSArguments struct {
	Cert             string            `river:"cert_pem,attr,optional"`
	CertFile         string            `river:"cert_file,attr,optional"`
	Key              rivertypes.Secret `river:"key_pem,attr,optional"`
	KeyFile          string            `river:"key_file,attr,optional"`
	ClientCA         string            `river:"client_ca_pem,attr,optional"`
	ClientCAFile     string            `river:"client_ca_file,attr,optional"`
	ClientAuth       ClientAuth        `river:"client_auth_type,attr,optional"`
	CipherSuites     []TLSCipher       `river:"cipher_suites,attr,optional"`
	CurvePreferences []TLSCurve        `river:"curve_preferences,attr,optional"`
	MinVersion       TLSVersion        `river:"min_version,attr,optional"`
	MaxVersion       TLSVersion        `river:"max_version,attr,optional"`

	// Windows Certificate Filter
	WindowsFilter *WindowsCertificateFilter `river:"windows_certificate_filter,block,optional"`
}

TLSArguments configures TLS settings for the HTTP service.

func (*TLSArguments) Validate added in v0.37.0

func (args *TLSArguments) Validate() error

Validate returns whether args is valid.

type TLSCipher added in v0.37.0

type TLSCipher uint16

TLSCipher holds the ID of a TLS cipher suite.

func (TLSCipher) MarshalText added in v0.37.0

func (c TLSCipher) MarshalText() ([]byte, error)

MarshalText marshals the ID of a cipher suite to its name.

func (*TLSCipher) UnmarshalText added in v0.37.0

func (c *TLSCipher) UnmarshalText(text []byte) error

UnmarshalText unmarshals the name of a cipher suite to its ID.

type TLSCurve added in v0.37.0

type TLSCurve tls.CurveID

TLSCurve holds the ID of a tls.CurveID.

func (TLSCurve) MarshalText added in v0.37.0

func (c TLSCurve) MarshalText() ([]byte, error)

MarshalText marshals the ID of a curve to its name.

func (*TLSCurve) UnmarshalText added in v0.37.0

func (c *TLSCurve) UnmarshalText(text []byte) error

UnmarshalText unmarshals the name of a curve to its ID.

type TLSVersion added in v0.37.0

type TLSVersion uint16

TLSVersion holds the ID of a TLS version.

func (TLSVersion) MarshalText added in v0.37.0

func (v TLSVersion) MarshalText() ([]byte, error)

MarshalText marshals the ID of a TLS version to its name.

func (*TLSVersion) UnmarshalText added in v0.37.0

func (v *TLSVersion) UnmarshalText(text []byte) error

UnmarshalText unmarshals the name of a TLS version to its ID.

type WindowsCertificateFilter added in v0.37.0

type WindowsCertificateFilter struct {
	Server *WindowsServerFilter `river:"server,block"`
	Client *WindowsClientFilter `river:"client,block"`
}

WindowsCertificateFilter represents the configuration for accessing the Windows store

type WindowsClientFilter added in v0.37.0

type WindowsClientFilter struct {
	IssuerCommonNames []string `river:"issuer_common_names,attr,optional"`
	SubjectRegEx      string   `river:"subject_regex,attr,optional"`
	TemplateID        string   `river:"template_id,attr,optional"`
}

WindowsClientFilter is used to select a client root CA certificate

type WindowsServerFilter added in v0.37.0

type WindowsServerFilter struct {
	Store             string        `river:"store,attr,optional"`
	SystemStore       string        `river:"system_store,attr,optional"`
	IssuerCommonNames []string      `river:"issuer_common_names,attr,optional"`
	TemplateID        string        `river:"template_id,attr,optional"`
	RefreshInterval   time.Duration `river:"refresh_interval,attr,optional"`
}

WindowsServerFilter is used to select a server certificate

func (*WindowsServerFilter) SetToDefault added in v0.37.0

func (wcf *WindowsServerFilter) SetToDefault()

SetToDefault sets the default for WindowsServerFilter

Jump to

Keyboard shortcuts

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