server

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Token string
}

Options for creating a server.

type Server

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

func NewServer

func NewServer(logger *slog.Logger, client client.Interface, opts Options) *Server

func (*Server) CreateHandler

func (s *Server) CreateHandler() http.Handler

func (*Server) GetStatistics

func (s *Server) GetStatistics() Stats

func (*Server) ResetStatistics

func (s *Server) ResetStatistics()

type Stats

type Stats struct {
	ErrorsCount           int `slog:"errors"`
	UploadCount           int `slog:"uploads"`
	ExistsYesCount        int `slog:"exists_yes"`
	ExistsNoCount         int `slog:"exists_no"`
	DownloadCount         int `slog:"downloads"`
	DownloadNotFoundCount int `slog:"downloads_not_found"`

	UploadedBytes   int64 `slog:"ul_bytes"`
	DownloadedBytes int64 `slog:"dl_bytes"`
}

Stats holds statistics for server operation. Can be requested with Server.GetStatistics().

func (Stats) SlogArgs

func (st Stats) SlogArgs() (result []any)

SlogArgs converts stats to an array than can be passed to slog logging functions. For example, slog.Info("server stats", stats.SlogArgs()...)

Jump to

Keyboard shortcuts

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