vroomy

package module
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2022 License: MIT Imports: 16 Imported by: 13 modules, 30 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Vroomy

All Contributors

billboard Vroomy is a plugin-based server. Vroomy can be used for anything, from a static file server to a full-blown back-end service!

Installation

Installing by compilation is very straight forward. The following dependencies are required:

  • Go
  • GCC
Fresh Install

If you need to install vroomy use this method! (This installs vroomy, vpm, and all of their dependencies)

curl -s https://raw.githubusercontent.com/vroomy/vroomy/main/bin/init | bash -s
Self Upgrade

If you already have vroomy installed, it can upgrade itself! (NOTE: this will attempt to self-sign vroomy on osx and support setcap for selinux. For more info, check the directions during install process)

vroomy upgrade && vpm upgrade

Usage

Test vroomy (run without http listen)
# Set custom config location (remember to revert if desired)
vroomy test
Start (with default config)
# With default config (./config.toml)
vroomy
Start with custom config
# Set custom config location (remember to revert if desired)
export VROOMY_CONFIG="custom.toml"
vroomy
Update plugins
vpm update
Update plugins with custom config
vpm update -config custom.toml
Update plugins with branch/channel
vpm update -b staging
Update filtered plugins
vpm update plugin1 plugin2
Update specific plugin at specific version
vpm update plugin1 -b v0.1.0

Example configuration

port = 8080
tlsPort = 10443 
tlsDir = "./tls"

[[route]]
httpPath = "/"
target = "./public_html/index.html"

[[route]]
httpPath = "/js/*"
target = "./public_html/js"

[[route]]
httpPath = "/css/*"
target = "./public_html/css"

Note: Please see config.example.toml for a more in depth example

Performance
# nginx
$ wrk -c60 -d20s https://josh.usehatchapp.com
Running 20s test @ https://josh.usehatchapp.com
  2 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    17.66ms    1.59ms  30.31ms   88.20%
    Req/Sec     1.68k   102.72     1.91k    85.43%
  66500 requests in 20.01s, 7.44GB read
Requests/sec:   3323.69
Transfer/sec:    380.91MB

# vroomy
$ wrk -c60 -d20s https://josh.usehatchapp.com
Running 20s test @ https://josh.usehatchapp.com
  2 threads and 60 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    14.28ms    9.45ms  98.77ms   73.79%
    Req/Sec     2.17k   304.46     3.03k    76.52%
  86013 requests in 20.01s, 9.62GB read
Requests/sec:   4297.88
Transfer/sec:    492.22MB

Dynamic Commands/Flags

Commands and flags can be added in config.toml and will automatically print in vroomy help handler represents the plugin.method of a command handler.

Example: 
[[command]]
name = "seed"
prehook = "cmd to exec before initializing plugins (such as backing up data directory)"
usage = "Use `vroomy seed` to execute the seed plugin handler\n  Accepts flag -seedfile <filepath>"
handler = "seed.Reseed"
posthook = "cmd to exec after closing plugins (such as backing archiving backup, or rolling back data)"

[[flag]]
name = "seedfile"
defaultValue = "test"
usage = "Set the seed file (i.e. \"custom.json\" when you want to run a custom seed"

Default Commands

These are provided by default and are "reserved" commands. They cannot be used in dynamic configs. :: vroomy :: Usage ::

vroomy

:: Runs vroomy server. Accepts flags specified in config.toml. Use vroomy or vroomy -<flag>

vroomy test

:: Tests the currently built plugins for compatibility. Closes service upon successful execution. Avoids port binding. Use vroomy test

vroomy help

:: Prints available commands and flags. Use vroomy help <command> or vroomy help <-flag> to get more specific info.

vroomy version

:: Prints current version of vroomy installation. Use vroomy version

vroomy upgrade

:: Upgrades vroomy installation itself. Skips if version is up to date. Use vroomy upgrade or vroomy upgrade <branch>

Flags

[-require -r]

:: Initializes only the specified "required" plugins. Allows optimized custom commands. Use vroomy test -r <plugin> <plugin>

[-dataDir -d]

:: Initializes backends in provided directory. Overrides value set in config and default values. Ignored when testing in favor of dir "testData".
Use vroomy -d <dir>

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Josh

💻 📖

Derek Halman

💻

Matt Stay

🎨

This project follows the all-contributors specification. Contributions of any kind welcome!

Documentation

Index

Constants

View Source
const (
	// ErrInvalidTLSDirectory is returned when a tls directory is unset when the tls port has been set
	ErrInvalidTLSDirectory = errors.Error("invalid tls directory, cannot be empty when tls port has been set")
	// ErrInvalidPreInitFunc is returned when an unsupported pre initialization function is encountered
	ErrInvalidPreInitFunc = errors.Error("unsupported header for Init func encountered")
	// ErrInvalidLoadFunc is returned when an unsupported initialization function is encountered
	ErrInvalidLoadFunc = errors.Error("unsupported header for Load func encountered")
	// ErrNotAddressable is returned when a plugin is not addressable
	ErrNotAddressable = errors.Error("provided backend must be addressable")
	// ErrInvalidDir is returned when a directory is empty
	ErrInvalidDir = errors.Error("invalid directory, cannot be empty")
	// ErrPluginKeyExists is returned when a plugin cannot be added because it already exists
	ErrPluginKeyExists = errors.Error("plugin cannot be added, key already exists")
	// ErrPluginNotLoaded is returned when a plugin namespace is provided that has not been loaded
	ErrPluginNotLoaded = errors.Error("plugin with that key has not been loaded")
	// ErrExpectedEndParen is returned when an ending parenthesis is missing
	ErrExpectedEndParen = errors.Error("expected ending parenthesis")
)

Variables

This section is empty.

Functions

func Register added in v0.11.0

func Register(key string, pi Plugin) error

Register will register a plugin with a given key

Types

type BasePlugin added in v0.11.0

type BasePlugin struct{}

func (*BasePlugin) Backend added in v0.11.0

func (b *BasePlugin) Backend() interface{}

func (*BasePlugin) Close added in v0.11.0

func (b *BasePlugin) Close() error

func (*BasePlugin) Init added in v0.11.0

func (b *BasePlugin) Init(env Environment) error

func (*BasePlugin) Load added in v0.11.0

func (b *BasePlugin) Load(env Environment) error

type Environment added in v0.13.0

type Environment map[string]string

func (Environment) Get added in v0.13.0

func (e Environment) Get(key string) (out string)

func (Environment) Must added in v0.13.0

func (e Environment) Must(key string) (out string, err error)

type Plugin added in v0.11.0

type Plugin interface {
	Init(env Environment) error
	Load(env Environment) error
	Backend() interface{}
	Close() error
}

type Plugins added in v0.11.0

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

Plugins manages loaded plugins

func (*Plugins) Close added in v0.11.0

func (p *Plugins) Close() (err error)

Close will close plugins

func (*Plugins) Get added in v0.11.0

func (p *Plugins) Get(key string) (pi Plugin, err error)

Get will get a plugin by it's key

func (*Plugins) Loaded added in v0.11.0

func (p *Plugins) Loaded() (pm map[string]Plugin)

func (*Plugins) Register added in v0.11.0

func (p *Plugins) Register(key string, pi Plugin) (err error)

New will load a new plugin by plugin key The following formats are accepted as keys:

  • path/to/file/plugin.so
  • github.com/username/repository/pluginDir

func (*Plugins) Test added in v0.11.0

func (p *Plugins) Test() (err error)

Test will test all of the plugins

func (*Plugins) TestAsync added in v0.11.0

func (p *Plugins) TestAsync(q *queue.Queue) (err error)

TestAsync will test all of the plugins asynchronously

type Vroomy added in v0.9.0

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

Vroomy manages the web service

func New

func New(configLocation string) (sp *Vroomy, err error)

New will return a new instance of service

func NewWithConfig added in v0.9.0

func NewWithConfig(cfg *config.Config) (vp *Vroomy, err error)

NewWithConfig will return a new instance of service with a provided config

func (*Vroomy) Close added in v0.9.0

func (v *Vroomy) Close() (err error)

Close will close the selected service

func (*Vroomy) Listen added in v0.9.0

func (v *Vroomy) Listen(ctx context.Context) (err error)

Listen will listen to the configured port

func (*Vroomy) Port added in v0.9.0

func (v *Vroomy) Port() uint16

Port will return the current HTTP port

func (*Vroomy) TLSPort added in v0.9.0

func (v *Vroomy) TLSPort() uint16

TLSPort will return the current HTTPS port

Jump to

Keyboard shortcuts

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