core

package
v0.0.0-...-d94da1c Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ScheduledTestTableName = "scheduled_test"

ScheduledTest is an incoming feature

View Source
const StressTestTableName = "stress_test"

Variables

View Source
var NoDBConn = errors.New("No database connection")
View Source
var Tables = map[string]map[string]string{
	StressTestTableName: map[string]string{
		"id":     "UUID PRIMARY KEY",
		"report": "text",
		"meta":   "WITH default_time_to_live = " + "604800",
	},
}

Tables metadata that will be used to generate tables

Functions

func FileReportsView

func FileReportsView(wr http.ResponseWriter, req *http.Request)

func HealthHandlerView

func HealthHandlerView(wr http.ResponseWriter, req *http.Request)

func InjectWsContext

func InjectWsContext(app *App, fn func(app *App, ws *websocket.Conn)) func(*websocket.Conn)

func Middleware

func Middleware(a *App, endpoint APIendpoint) http.HandlerFunc

Middleware sets custom headers, and writes json response

func PrometheusHandlerView

func PrometheusHandlerView(wr http.ResponseWriter, req *http.Request)

func TestHandlerView

func TestHandlerView(wr http.ResponseWriter, req *http.Request)

func WriteAllWebsockets

func WriteAllWebsockets(report *ustress.Report) error

func WsServer

func WsServer(app *App, ws *websocket.Conn)

WsServer handles the ws connections

Types

type APIendpoint

type APIendpoint func(a *App, w http.ResponseWriter, r *http.Request) (interface{}, error)

APIendpoint ...

type App

type App struct {
	Version       string
	Configuration *Config
	Session       *gocql.Session
}

App will store app state, and other metadata alongside with utility functions

func NewApp

func NewApp(version string, c *Config) *App

NewApp inits the app

func NewAppFromEnv

func NewAppFromEnv(cassandraEnv string) (*App, error)

NewAppFromEnv Gets configuration from env

func NewAppFromYAML

func NewAppFromYAML(configpath string) *App

NewAppFromYAML inits the app from a yaml file

func (*App) CreateSchema

func (a *App) CreateSchema()

CreateSchema generates the required tables

func (*App) Init

func (a *App) Init()

Init initializes app

func (*App) InitSession

func (a *App) InitSession() error

InitSession initializes a cassandra session and attaches to the app struct

type Config

type Config struct {
	Hosts                        []string
	Port                         int
	Keyspace, Username, Password string
}

func LocalCassandraConfig

func LocalCassandraConfig() *Config

LocalCassandraConfig Used for development

func NewConfig

func NewConfig(cassEnv string) (*Config, error)

type JSONResponse

type JSONResponse map[string]interface{}

type StressTest

type StressTest struct {
	ID     uuid.UUID       `gocql:"id"`
	Report *ustress.Report `gocql:"report"`
}

func NewStressTest

func NewStressTest(report *ustress.Report) *StressTest

func (*StressTest) All

func (test *StressTest) All(sess *gocql.Session) ([]map[string]interface{}, error)

func (*StressTest) Get

func (test *StressTest) Get(sess *gocql.Session) error

func (*StressTest) Save

func (test *StressTest) Save(sess *gocql.Session) error

Jump to

Keyboard shortcuts

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