server

package
v4.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitPeerMeta

func InitPeerMeta(meta map[string]string)

Types

type CoreServer added in v4.0.1

type CoreServer interface {
	Name() string
	ID() string
	Type() Type
	As(interface{}) bool
}

type HttpMux

type HttpMux interface {
	Handler(r *http.Request) (h http.Handler, pattern string)
	ServeHTTP(w http.ResponseWriter, r *http.Request)
	Handle(pattern string, handler http.Handler)
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}

type ListableMux

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

ListableMux is a simple rewrite of http.ServeMux with accessor to the list of registered patterns

func NewListableMux

func NewListableMux() *ListableMux

NewListableMux allocates and returns a new ListableMux.

func (*ListableMux) DeregisterPattern added in v4.0.1

func (mux *ListableMux) DeregisterPattern(pattern string)

func (*ListableMux) Handle

func (mux *ListableMux) Handle(pattern string, handler http.Handler)

Handle registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.

func (*ListableMux) HandleFunc

func (mux *ListableMux) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))

HandleFunc registers the handler function for the given pattern.

func (*ListableMux) Handler

func (mux *ListableMux) Handler(r *http.Request) (h http.Handler, pattern string)

Handler returns the handler to use for the given request, consulting r.Method, r.Host, and r.URL.Path. It always returns a non-nil handler. If the path is not in its canonical form, the handler will be an internally-generated handler that redirects to the canonical path. If the host contains a port, it is ignored when matching handlers.

The path and host are used unchanged for CONNECT requests.

Handler also returns the registered pattern that matches the request or, in the case of internally-generated redirects, the pattern that will match after following the redirect.

If there is no registered handler that applies to the request, Handler returns a “page not found” handler and an empty pattern.

func (*ListableMux) Patterns

func (mux *ListableMux) Patterns() (patterns []string)

Patterns list registered patterns using the internal lock on the mux.m map

func (*ListableMux) ServeHTTP

func (mux *ListableMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches the request to the handler whose pattern most closely matches the request URL.

type Option added in v4.0.1

type Option func(*Options)

Option is a function to set Options

type Options added in v4.0.1

type Options struct {
	Context  context.Context
	Listener *net.Listener
	Metadata map[string]string
}

Options stores all options for a pydio server

type PatternsProvider

type PatternsProvider interface {
	Patterns() []string
	DeregisterPattern(pattern string)
}

type RawServer

type RawServer interface {
	CoreServer
	Stop() error
	RawServe(options *ServeOptions) ([]registry.Item, error)
}

type ServeOption added in v4.0.1

type ServeOption func(options *ServeOptions)

func WithAfterServe added in v4.0.1

func WithAfterServe(f func(oo ...registry.RegisterOption) error) ServeOption

func WithBeforeServe added in v4.0.1

func WithBeforeServe(f func(oo ...registry.RegisterOption) error) ServeOption

func WithBlockUntilServe added in v4.0.1

func WithBlockUntilServe() ServeOption

func WithErrorCallback added in v4.0.1

func WithErrorCallback(cb func(err error)) ServeOption

func WithGrpcBindAddress added in v4.0.1

func WithGrpcBindAddress(a string) ServeOption

func WithHttpBindAddress added in v4.0.1

func WithHttpBindAddress(a string) ServeOption

type ServeOptions added in v4.0.1

type ServeOptions struct {
	HttpBindAddress string
	GrpcBindAddress string
	ErrorCallback   func(error)
	BlockUntilServe bool

	BeforeServe []func(oo ...registry.RegisterOption) error
	AfterServe  []func(oo ...registry.RegisterOption) error

	RegistryOptions []registry.RegisterOption
}

type Server

type Server interface {
	CoreServer
	Serve(...ServeOption) error
	Stop(oo ...registry.RegisterOption) error

	Is(status registry.Status) bool
	NeedsRestart() bool
	Metadata() map[string]string
}

func NewServer

func NewServer(ctx context.Context, s RawServer) Server

func OpenServer added in v4.0.1

func OpenServer(ctx context.Context, urlstr string) (Server, error)

OpenServer opens the Registry identified by the URL given. See the URLOpener documentation in driver subpackages for details on supported URL formats, and https://gocloud.dev/concepts/urls for more information.

type Type added in v4.0.1

type Type int8
const (
	TypeGrpc Type = iota
	TypeHttp
	TypeHttpPure
	TypeGeneric
	TypeFork
)

type URLMux added in v4.0.1

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

URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.

The zero value is a multiplexer with no registered schemes.

func DefaultURLMux added in v4.0.1

func DefaultURLMux() *URLMux

DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.

Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.

func (*URLMux) OpenServer added in v4.0.1

func (mux *URLMux) OpenServer(ctx context.Context, urlstr string) (Server, error)

OpenServer calls OpenTopicURL with the URL parsed from urlstr. OpenTopic is safe to call from multiple goroutines.

func (*URLMux) Register added in v4.0.1

func (mux *URLMux) Register(scheme string, opener URLOpener)

Register registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.

func (*URLMux) Schemes added in v4.0.1

func (mux *URLMux) Schemes() []string

Schemes returns a sorted slice of the registered schemes.

func (*URLMux) ValidScheme added in v4.0.1

func (mux *URLMux) ValidScheme(scheme string) bool

ValidScheme returns true if scheme has been registered.

type URLOpener added in v4.0.1

type URLOpener interface {
	OpenURL(ctx context.Context, u *url.URL) (Server, error)
}

URLOpener represents types than can open Registries based on a URL. The opener must not modify the URL argument. OpenURL must be safe to call from multiple goroutines.

This interface is generally implemented by types in driver packages.

Directories

Path Synopsis
mux
Package servercontext performs context values read/write, generally through server or client wrappers
Package servercontext performs context values read/write, generally through server or client wrappers
mux

Jump to

Keyboard shortcuts

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