servertools

package module
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: LGPL-3.0 Imports: 25 Imported by: 23

README

Commit Shield Issues Shield License Shield



FestivalsApp Server Tools

The festivals server tools repository contains server functions shared between server components of the FestivalsApp.


DevelopmentDeploymentEngage


Development

This repository serves as a toolkit for shared functionality among the server components of the FestivalsApp. It consolidates common tasks like sending a heartbeat to the festivals-gateway, updating server binaries from GitHub, responding to client requests, and more. By centralizing these functions, the repository reduces code duplication, simplifies maintenance, and makes refactoring easier.

See the DOCUMENTATION for more information about the components of the servertools package.

The development of festivals-server-tools is closely tied to the specific functionality it supports. For example, the heartbeat sender implementation relies heavily on the festivals-gateway implementation, whereas the response tools are designed to operate independently of other project components. Each task is designed to minimize dependencies, ensuring the tools remain lightweight and efficient. However, direct imports from any other FestivalsApp components are strictly prohibited.

Requirements

Deployment

Add the festivals-server-tools to your go project by running this command

go get github.com/festivals-app/festivals-server-tools

Engage

I welcome every contribution, whether it is a pull request or a fixed typo. The best place to discuss questions and suggestions regarding the festivals-server-tools is the issues section. More general information and a good starting point if you want to get involved is the festival-documentation repository.

The following channels are available for discussions, feedback, and support requests:

Type Channel
General Discussion General Discussion Shield
Other Requests Other Requests Shield

Licensing

Copyright (c) 2023-2025 Simon Gaus. Licensed under the GNU Lesser General Public License v3.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerPathArgument added in v0.0.6

func ContainerPathArgument() string

Checks if the binary was executed with the --container="/path/to/container" argument and returns the specified path or an empty string.

func DebugArgument added in v0.0.7

func DebugArgument() bool

Checks if the binary was executed with the --debug argument.

func ExpandTilde added in v0.0.7

func ExpandTilde(path string) string

ExpandTilde expands a leading tilde (~) to the user's home directory who runs the binary.

func FileExists

func FileExists(filename string) bool

Checks if a file exists and isn't a directory. see: https://golangcode.com/check-if-a-file-exists/

func GetFileContentType added in v0.0.10

func GetFileContentType(file *os.File) (string, error)

func HeartbeatClient

func HeartbeatClient(clientCert string, clientKey string, serverCA string) (*http.Client, error)

func InitializeGlobalLogger

func InitializeGlobalLogger(logfile string, console bool)

func LatestVersion added in v0.0.2

func LatestVersion(organisation string, repository string) (string, error)

func Middleware

func Middleware(traceLogger *zerolog.Logger) func(next http.Handler) http.Handler

func NewRollingFile

func NewRollingFile(file string) (io.Writer, error)

func RespondCode

func RespondCode(w http.ResponseWriter, code int)

func RespondError

func RespondError(w http.ResponseWriter, code int, message string)

func RespondFile added in v0.0.10

func RespondFile(w http.ResponseWriter, file *os.File)

respondFile makes the response with payload as json format

func RespondJSON

func RespondJSON(w http.ResponseWriter, status int, payload interface{})

func RespondString

func RespondString(w http.ResponseWriter, code int, message string)

func RunUpdate added in v0.0.2

func RunUpdate(currentVersion string, organisation string, repository string, updateScriptPath string) (string, error)

func SendHeartbeat

func SendHeartbeat(client *http.Client, endpoint string, serviceKey string, beat *Heartbeat) error

func TraceLogger

func TraceLogger(logfile string) *zerolog.Logger

func UnauthorizedResponse added in v0.0.3

func UnauthorizedResponse(w http.ResponseWriter)

Types

type Heartbeat

type Heartbeat struct {
	Service   string `json:"service"`
	Host      string `json:"host"`
	Port      int    `json:"port"`
	Available bool   `json:"available"`
}

type Service added in v0.0.10

type Service string
const (
	Gateway    Service = "festivals-gateway"
	Identity   Service = "festivals-identity-server"
	Server     Service = "festivals-server"
	Fileserver Service = "festivals-fileserver"
	Database   Service = "festivals-database-node"
	Website    Service = "festivals-website-node"
)

func ValidService added in v0.0.11

func ValidService(s string) (service Service, err error)

func (Service) Value added in v0.0.11

func (service Service) Value() string

Jump to

Keyboard shortcuts

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