gateway

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: Apache-2.0 Imports: 70 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigNotFound = errors.New("config not found")
	ErrAlreadyExists  = errors.New("already exists")
	ErrNoLiveUpstream = errors.New("no live upstreams while connecting to upstream")
)

Functions

func DisableGopool

func DisableGopool() error

func Run

func Run(mainOptions config.Options) (err error)

Run starts the bifrost server with the given options.

mainOptions is the configuration for the bifrost server. err is the error that occurred during the startup process.

func RunAsDaemon

func RunAsDaemon(mainOptions config.Options) error

RunAsDaemon runs the current process as a daemon.

It takes mainOptions of type config.Options which contains the user and group information to run the daemon process. Returns an error if the daemon process fails to start.

func SetBifrost

func SetBifrost(bifrost *Bifrost)

SetBifrost sets the current instance of Bifrost. It stores the given Bifrost instance in the defaultBifrost atomic value. This function is used to set the Bifrost instance after it has been created. It is typically called by the top-level application code to initialize the Bifrost instance.

func StopDaemon

func StopDaemon(mainOptions config.Options) error

StopDaemon stops the daemon process.

It takes mainOptions of type config.Options which contains the upgrade socket and PID file information. Returns an error if the daemon process fails to stop.

func Upgrade

func Upgrade(mainOptions config.Options) error

Upgrade upgrades the daemon process.

It takes mainOptions of type config.Options which contains the upgrade socket and PID file information. Returns an error if the upgrade fails.

Types

type Bifrost

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

func GetBifrost

func GetBifrost() *Bifrost

GetBifrost retrieves the current instance of Bifrost. It returns a pointer to the Bifrost instance stored in the defaultBifrost atomic value.

func NewBifrost

func NewBifrost(mainOptions config.Options, isReload bool) (*Bifrost, error)

NewBifrost creates a new instance of Bifrost.

It takes in two parameters: mainOptions of type config.Options and isReload of type bool. The mainOptions parameter contains the main configuration options for the Bifrost instance. The isReload parameter indicates whether the function is being called during a reload operation. The function returns a pointer to Bifrost and an error.

func (*Bifrost) IsActive

func (b *Bifrost) IsActive() bool

IsActive returns whether the Bifrost is active or not. It returns true if the Bifrost is active, false otherwise.

func (*Bifrost) Run

func (b *Bifrost) Run()

Run starts all HTTP servers in the Bifrost instance. The last server is started in the current goroutine, and the function will block until the last server stops. The other servers are started in separate goroutines.

func (*Bifrost) Service

func (b *Bifrost) Service(serviceID string) (*Service, bool)

Service retrieves a service by its ID from the Bifrost instance. It returns a pointer to the Service and a boolean indicating whether the service was found. If the serviceID does not exist, the returned Service pointer will be nil and the boolean will be false.

func (*Bifrost) SetActive

func (b *Bifrost) SetActive(value bool)

SetActive sets whether the Bifrost is active or not. If the value is true, Bifrost will be set to active, otherwise it will be set to inactive.

func (*Bifrost) Shutdown

func (b *Bifrost) Shutdown(ctx context.Context) error

Shutdown shuts down all HTTP servers in the Bifrost instance gracefully. It blocks until all servers finish their shutdown process. The function returns an error if any server fails to shut down.

func (*Bifrost) ShutdownNow

func (b *Bifrost) ShutdownNow(ctx context.Context) error

func (*Bifrost) ZeroDownTime

func (b *Bifrost) ZeroDownTime() *zero.ZeroDownTime

type DynamicService

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

func (*DynamicService) ServeHTTP

func (svc *DynamicService) ServeHTTP(c context.Context, ctx *app.RequestContext)

type Engine

type Engine struct {
	ID string
	// contains filtered or unexported fields
}

func (*Engine) OnShutdown

func (e *Engine) OnShutdown()

func (*Engine) ServeHTTP

func (e *Engine) ServeHTTP(ctx context.Context, c *app.RequestContext)

func (*Engine) Use

func (e *Engine) Use(middleware ...app.HandlerFunc)

type HTTPServer

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

func (*HTTPServer) Bind

func (s *HTTPServer) Bind() string

func (*HTTPServer) Engine

func (s *HTTPServer) Engine() *Engine

func (*HTTPServer) Run

func (s *HTTPServer) Run()

func (*HTTPServer) SetEngine

func (s *HTTPServer) SetEngine(engine *Engine)

func (*HTTPServer) Shutdown

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

type PromMetricMiddleware

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

func (*PromMetricMiddleware) ServeHTTP

func (m *PromMetricMiddleware) ServeHTTP(ctx context.Context, c *app.RequestContext)

type Router

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

Router struct contains the Trie and handler chain

type Routes

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

func (*Routes) Add

func (r *Routes) Add(routeOpts config.RouteOptions, middlewares ...app.HandlerFunc) error

Add adds a new route

func (*Routes) ServeHTTP

func (r *Routes) ServeHTTP(c context.Context, ctx *app.RequestContext)

ServeHTTP implements the http.Handler interface

type Service

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

func (*Service) Middlewares

func (svc *Service) Middlewares() []app.HandlerFunc

func (*Service) ServeHTTP

func (svc *Service) ServeHTTP(c context.Context, ctx *app.RequestContext)

type Upstream

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

Jump to

Keyboard shortcuts

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