db

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertClient

type AlertClient struct {
	*ent.AlertClient
	// contains filtered or unexported fields
}

AlertClient is a wrapper enhaning the ent client

func (*AlertClient) Save

func (ac *AlertClient) Save(ctx context.Context, msg *msg.AlertMsg) error

Save an alert msg to ent

func (*AlertClient) Szenarios

func (ac *AlertClient) Szenarios(ctx context.Context) ([]string, error)

Szenarios returns a list of szenario names

type Client

type Client struct {
	*ent.Client

	// IncidentSummary is the query for incident summaries
	IncidentSummary *IncidentSummaryQuery

	// Incident wraps and enhances the ent IncidentClient
	Incident *IncidentClient
	// Alert wraps and enhances the ent AlertClient
	Alert *AlertClient
	// contains filtered or unexported fields
}

Client gives access to the DB and wraps ent

func New

func New() (*Client, error)

New creates an ent access

func (*Client) ThinOutIncidents added in v0.10.11

func (c *Client) ThinOutIncidents(ctx context.Context) error

ThinOutIncidents removes multiple incident entries

type IncidentClient

type IncidentClient struct {
	*ent.IncidentClient
	// contains filtered or unexported fields
}

IncidentClient is a wrapper enhaning the ent client

func (*IncidentClient) Save

func (ic *IncidentClient) Save(ctx context.Context, msg *msg.IncidentMsg) error

Save save an incident msg to ent

func (*IncidentClient) Szenarios

func (ic *IncidentClient) Szenarios(ctx context.Context) ([]string, error)

Szenarios returns a list of szenario names

type IncidentSummary

type IncidentSummary struct {
	IncidentID uuid.UUID  `json:"incident_id"`
	Name       string     `json:"name"`
	Total      int        `json:"total"`
	IntLevel   int        `json:"level"`
	Start      MinMaxTime `json:"start"`
	End        MinMaxTime `json:"end"`
	LastUpdate MinMaxTime `json:"time"`
	Error      string     `json:"error"`
}

IncidentSummary is the summary of different incidents entries

func (IncidentSummary) Level

func (is IncidentSummary) Level() status.Level

Level convinience method that calls status Level

type IncidentSummaryQuery

type IncidentSummaryQuery struct {
	*ent.IncidentQuery
	// contains filtered or unexported fields
}

IncidentSummaryQuery allows quering incidents

func (*IncidentSummaryQuery) All

All returns all incudent summaries

func (IncidentSummaryQuery) CloseIncident added in v0.12.3

func (isq IncidentSummaryQuery) CloseIncident(ctx context.Context, is *IncidentSummary, username string, statusLevel status.Level, failure string) error

func (*IncidentSummaryQuery) First added in v0.10.0

First wrap ent first

func (*IncidentSummaryQuery) Query

Query returns a list of incidents

func (*IncidentSummaryQuery) Where added in v0.10.0

Where wrap ent where

type MinMaxTime

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

MinMaxTime is a wrapper around time to support SQL max and min

func (MinMaxTime) After

func (mmt MinMaxTime) After(t MinMaxTime) bool

After is wraps time.Time.After

func (MinMaxTime) Before

func (mmt MinMaxTime) Before(t MinMaxTime) bool

Before is wraps time.Time.Before

func (MinMaxTime) IsZero

func (mmt MinMaxTime) IsZero() bool

IsZero is wraps time.Time.IsZero

func (*MinMaxTime) Scan

func (mmt *MinMaxTime) Scan(value interface{}) error

Scan scan value the time, implements sql.Scanner interface

func (MinMaxTime) Since added in v0.10.3

func (mmt MinMaxTime) Since(t MinMaxTime) time.Duration

Since returns the underlying time

func (MinMaxTime) String

func (mmt MinMaxTime) String() string

String formats the time

func (MinMaxTime) Time

func (mmt MinMaxTime) Time() time.Time

Time returns the underlying time

func (MinMaxTime) Value

func (mmt MinMaxTime) Value() (driver.Value, error)

Value return the time, implement driver.Valuer interface

Directories

Path Synopsis
ent

Jump to

Keyboard shortcuts

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