- Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathsession.go
50 lines (43 loc) · 1.33 KB
/
session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
2020 © Postgres.ai
*/
// Package observer provides clone monitoring.
package observer
import (
"time"
"gitlab.com/postgres-ai/database-lab/v3/pkg/client/dblabapi/types"
"gitlab.com/postgres-ai/database-lab/v3/pkg/models"
)
// Session describes a session of service monitoring.
typeSessionstruct {
SessionIDuint64`json:"session_id"`
StartedAt time.Time`json:"started_at"`
FinishedAt time.Time`json:"finished_at"`
Config types.Config`json:"config"`
Tagsmap[string]string`json:"tags"`
Artifacts []string`json:"artifacts,omitempty"`
Result*models.ObservationResult`json:"result,omitempty"`
stateState
}
// State contains database state of the session.
typeStatestruct {
InitialDBSizeint64
CurrentDBSizeint64
MaxDBQueryTimeMSfloat64
ObjectStatObjectsStat
LogErrorsLogErrors
OverallErrorbool
}
// NewSession creates a new observing session.
funcNewSession(sessionIDuint64, startedAt time.Time, config types.Config, tagsmap[string]string) *Session {
return&Session{
SessionID: sessionID,
StartedAt: startedAt,
Config: config,
Tags: tags,
}
}
// IsFinished checks if the value FinishedAt is zero.
func (sSession) IsFinished() bool {
return!s.FinishedAt.IsZero()
}