Skip to content

server #

This module contains the Vieter HTTP server, consisting of the repository implementation & the REST API.

NOTE: vweb defines the priority order of routes by the file names in this module. Therefore, it's very important that all API routes are defined in files prefixed with api_, as this is before the word routes alphabetically.

Constants #

const fallback_log_removal_frequency = 24 * time.hour
const (
	log_file_name = 'vieter.log'
	repo_dir_name = 'repos'
	db_file_name  = 'vieter.sqlite'
	logs_dir_name = 'logs'
)

fn cmd #

pub fn cmd() cli.Command

cmd returns the cli submodule that handles starting the server

fn parse_query_time #

fn parse_query_time(query string) !time.Time

parse_query_time unescapes an HTTP query parameter & tries to parse it as a time.Time struct.

fn server #

pub fn server(conf Config) !

server starts the web server & starts listening for requests

struct App #

struct App {
	web.Context
pub:
	conf Config [required; web_global]
pub mut:
	repo repo.RepoGroupManager [required; web_global]
// Keys are the various architectures for packages
	job_queue BuildJobQueue [required; web_global]
	db        dbms.VieterDb
}

fn (App) delete_arch_repo #

fn (mut app App) delete_arch_repo(repo string, arch string) web.Result

delete_arch_repo tries to remove the given arch-repo.

fn (App) delete_package #

fn (mut app App) delete_package(repo string, arch string, pkg string) web.Result

delete_package tries to remove the given package.

fn (App) delete_repo #

fn (mut app App) delete_repo(repo string) web.Result

delete_repo tries to remove the given repo.

fn (App) get_repo_file #

fn (mut app App) get_repo_file(repo_ string, arch string, filename string) web.Result

get_repo_file handles all Pacman-related routes. It returns both the repository's archives, but also package archives or the contents of a package's desc file.

fn (App) healthcheck #

pub fn (mut app App) healthcheck() web.Result

healthcheck just returns a string, but can be used to quickly check if the server is still responsive.

fn (App) init_job_queue #

fn (mut app App) init_job_queue() !

init_job_queue populates a fresh job queue with all the targets currently stored in the database.

fn (App) log_removal_daemon #

fn (mut app App) log_removal_daemon(schedule &cron.Expression)

log_removal_daemon removes old build logs every log_removal_frequency.

fn (App) put_package #

fn (mut app App) put_package(repo_ string) web.Result

put_package handles publishing a package to a repository.

fn (App) v1_delete_log #

fn (mut app App) v1_delete_log(id int) web.Result

v1_delete_log allows removing a build log from the system.

fn (App) v1_delete_target #

fn (mut app App) v1_delete_target(id int) web.Result

v1_delete_target removes a given target from the server's list.

fn (App) v1_get_log_content #

fn (mut app App) v1_get_log_content(id int) web.Result

v1_get_log_content returns the actual build log file for the given id.

fn (App) v1_get_logs #

fn (mut app App) v1_get_logs() web.Result

v1_get_logs returns all build logs in the database. A 'target' query param can optionally be added to limit the list of build logs to that repository.

fn (App) v1_get_single_log #

fn (mut app App) v1_get_single_log(id int) web.Result

v1_get_single_log returns the build log with the given id.

fn (App) v1_get_single_target #

fn (mut app App) v1_get_single_target(id int) web.Result

v1_get_single_target returns the information for a single target.

fn (App) v1_get_targets #

fn (mut app App) v1_get_targets() web.Result

v1_get_targets returns the current list of targets.

fn (App) v1_metrics #

fn (mut app App) v1_metrics() web.Result

v1_metrics serves a Prometheus-compatible metrics endpoint.

fn (App) v1_patch_target #

fn (mut app App) v1_patch_target(id int) web.Result

v1_patch_target updates a target's data with the given query params.

fn (App) v1_poll_job_queue #

fn (mut app App) v1_poll_job_queue() web.Result

v1_poll_job_queue allows agents to poll for new build jobs.

fn (App) v1_post_log #

fn (mut app App) v1_post_log() web.Result

v1_post_log adds a new log to the database.

fn (App) v1_post_target #

fn (mut app App) v1_post_target() web.Result

v1_post_target creates a new target from the provided query string.

fn (App) v1_queue_job #

fn (mut app App) v1_queue_job() web.Result

v1_queue_job allows queueing a new one-time build job for the given target.

struct Config #

struct Config {
pub:
	port                 int    = 8000
	log_level            string = 'WARN'
	pkg_dir              string
	data_dir             string
	api_key              string
	default_arch         string
	global_schedule      string = '0 3'
	base_image           string = 'archlinux:base-devel'
	max_log_age          int    [empty_default]
	log_removal_schedule string = '0 0'
	collect_metrics      bool   [empty_default]
}