database

package
v0.0.0-...-4305b7b Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Destroy

func Destroy(durl string) error

func Migrate

func Migrate(durl string) error

Types

type Check

type Check struct {
	ID   int    `db:"id"`
	UUID string `db:"uuid"`

	CreatedAt time.Time `db:"created_at"`
	EditedAt  time.Time `db:"edited_at"`

	// URL is the URL that this check will monitor.
	URL string `db:"url"`
	// WebhookURL is the URL that state changes will be POSTed to.
	WebhookURL string `db:"webhook_url"`
	// WebhookResponseTimeNanoseconds is the last response time of the
	// webhook URL in nanoseconds.
	WebhookResponseTimeNanoseconds int64 `db:"webhook_response_time_nanoseconds"`
	// Every is how often this check will run in seconds.
	// (minimum: 60, maximum: 600)
	Every int `db:"every"`
	// PlaybookURL is a URL for operations staff to respond to downtime of
	// the service that is backed by the URL above.
	PlaybookURL string `db:"playbook_url"`
	// State is the check's last known state.
	State string `db:"state"`
}

Check is an individual HTTP check that gets scheduled every so often.

func (Check) AsProto

func (c Check) AsProto() *lokahi.Check

AsProto converts this to the protobuf representation.

func (Check) F

func (c Check) F() ln.F

F ields for logging.

type Checks

type Checks interface {
	Create(ctx context.Context, c Check) (*Check, error)
	Delete(ctx context.Context, cid string) (*Check, error)
	Get(ctx context.Context, cid string) (*Check, error)
	ListByEveryValue(ctx context.Context, time int) ([]Check, error)
	List(ctx context.Context, count, offset int) ([]Check, error)
	Put(ctx context.Context, c Check) (*Check, error)
}

Checks is the set of calls that can be made to the database regarding checks

func ChecksPostgres

func ChecksPostgres(db *sqlx.DB) Checks

type Run

type Run struct {
	ID        int       `db:"id"`
	UUID      string    `db:"uuid"`
	CreatedAt time.Time `db:"created_at"`
	Message   string    `db:"message"`
}

type RunInfo

type RunInfo struct {
	ID                             int       `db:"id"`
	UUID                           string    `db:"uuid"`
	CreatedAt                      time.Time `db:"created_at"`
	RunID                          string    `db:"run_id"`
	CheckID                        string    `db:"check_id"`
	ResponseStatus                 int       `db:"response_status"`
	ResponseTimeNanoseconds        int64     `db:"response_time_nanoseconds"`
	WebhookResponseTimeNanoseconds int64     `db:"webhook_response_time_nanoseconds"`
}

type RunInfos

type RunInfos interface {
	GetRun(ctx context.Context, rid string) ([]RunInfo, error)
	Put(ctx context.Context, ri RunInfo) error
}

func RunInfosPostgres

func RunInfosPostgres(db *sqlx.DB) RunInfos

type Runs

type Runs interface {
	Get(ctx context.Context, rid string) (*Run, error)
	GetForCheck(ctx context.Context, cid string, limit, offset int) ([]Run, error)
	Put(ctx context.Context, rn Run) (*Run, error)
}

func RunsPostgres

func RunsPostgres(db *sqlx.DB) Runs

Jump to

Keyboard shortcuts

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