server

package
v0.0.0-...-58c64f7 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 75 Imported by: 0

Documentation

Overview

Package server implements Kopia API server handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssetFile

func AssetFile() http.FileSystem

AssetFile exposes HTML UI files.

Types

type InitRepositoryFunc

type InitRepositoryFunc func(ctx context.Context) (repo.Repository, error)

InitRepositoryFunc is a function that attempts to connect to/open repository.

func RetryInitRepository

func RetryInitRepository(initialize InitRepositoryFunc) InitRepositoryFunc

RetryInitRepository wraps provided initialization function with retries until the context gets canceled.

type Options

type Options struct {
	ConfigFile               string
	ConnectOptions           *repo.ConnectOptions
	RefreshInterval          time.Duration
	MaxConcurrency           int
	Authenticator            auth.Authenticator
	Authorizer               auth.Authorizer
	PasswordPersist          passwordpersist.Strategy
	AuthCookieSigningKey     string
	LogRequests              bool
	UIUser                   string // name of the user allowed to access the UI API
	UIPreferencesFile        string // name of the JSON file storing UI preferences
	ServerControlUser        string // name of the user allowed to access the server control API
	DisableCSRFTokenChecks   bool
	PersistentLogs           bool
	UITitlePrefix            string
	DebugScheduler           bool
	MinMaintenanceInterval   time.Duration
	EnableErrorNotifications bool
	NotifyTemplateOptions    notifytemplate.Options
}

Options encompasses all API server options.

type Server

type Server struct {
	OnShutdown func(ctx context.Context) error
	// contains filtered or unexported fields
}

Server exposes simple HTTP API for programmatically accessing Kopia features.

func New

func New(ctx context.Context, options *Options) (*Server, error)

New creates a Server. The server will manage sources for a given username@hostname.

func (*Server) GRPCRouterHandler

func (s *Server) GRPCRouterHandler(handler http.Handler) http.Handler

GRPCRouterHandler returns HTTP handler that supports GRPC services and routes non-GRPC calls to the provided handler.

func (*Server) InitRepositoryAsync

func (s *Server) InitRepositoryAsync(ctx context.Context, mode string, initializer InitRepositoryFunc, wait bool) (string, error)

InitRepositoryAsync starts a task that initializes the repository by invoking the provided callback and initializes the repository when done. The initializer may return nil to indicate there is no repository configured.

func (*Server) Refresh

func (s *Server) Refresh()

Refresh refreshes the state of the server in response to external signal (e.g. SIGHUP).

func (*Server) RegisterGRPCHandlers

func (s *Server) RegisterGRPCHandlers(r grpc.ServiceRegistrar)

RegisterGRPCHandlers registers server gRPC handler.

func (*Server) ServeStaticFiles

func (s *Server) ServeStaticFiles(m *mux.Router, fs http.FileSystem)

ServeStaticFiles configures HTTP handler that serves static files and dynamically patches index.html to embed CSRF token, etc.

func (*Server) Session

Session handles GRPC session from a repository client.

func (*Server) SetRepository

func (s *Server) SetRepository(ctx context.Context, rep repo.Repository) error

SetRepository sets the repository (nil is allowed and indicates server that is not connected to the repository).

func (*Server) SetupControlAPIHandlers

func (s *Server) SetupControlAPIHandlers(m *mux.Router)

SetupControlAPIHandlers registers control API handlers.

func (*Server) SetupHTMLUIAPIHandlers

func (s *Server) SetupHTMLUIAPIHandlers(m *mux.Router)

SetupHTMLUIAPIHandlers registers API requests required by the HTMLUI.

Jump to

Keyboard shortcuts

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