generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
models.go
270 lines (234 loc) · 5.51 KB
/
models.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.25.0
package sql
import (
"database/sql/driver"
"encoding/json"
"fmt"
"time"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/internal/model"
"github.com/alecthomas/types/optional"
)
type ControllerState string
const (
ControllerStateLive ControllerState = "live"
ControllerStateDead ControllerState = "dead"
)
func (e *ControllerState) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = ControllerState(s)
case string:
*e = ControllerState(s)
default:
return fmt.Errorf("unsupported scan type for ControllerState: %T", src)
}
return nil
}
type NullControllerState struct {
ControllerState ControllerState
Valid bool // Valid is true if ControllerState is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullControllerState) Scan(value interface{}) error {
if value == nil {
ns.ControllerState, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.ControllerState.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullControllerState) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.ControllerState), nil
}
type EventType string
const (
EventTypeCall EventType = "call"
EventTypeLog EventType = "log"
EventTypeDeploymentCreated EventType = "deployment_created"
EventTypeDeploymentUpdated EventType = "deployment_updated"
)
func (e *EventType) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = EventType(s)
case string:
*e = EventType(s)
default:
return fmt.Errorf("unsupported scan type for EventType: %T", src)
}
return nil
}
type NullEventType struct {
EventType EventType
Valid bool // Valid is true if EventType is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullEventType) Scan(value interface{}) error {
if value == nil {
ns.EventType, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.EventType.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullEventType) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.EventType), nil
}
type Origin string
const (
OriginIngress Origin = "ingress"
OriginCron Origin = "cron"
OriginPubsub Origin = "pubsub"
)
func (e *Origin) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = Origin(s)
case string:
*e = Origin(s)
default:
return fmt.Errorf("unsupported scan type for Origin: %T", src)
}
return nil
}
type NullOrigin struct {
Origin Origin
Valid bool // Valid is true if Origin is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullOrigin) Scan(value interface{}) error {
if value == nil {
ns.Origin, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.Origin.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullOrigin) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.Origin), nil
}
type RunnerState string
const (
RunnerStateIdle RunnerState = "idle"
RunnerStateReserved RunnerState = "reserved"
RunnerStateAssigned RunnerState = "assigned"
RunnerStateDead RunnerState = "dead"
)
func (e *RunnerState) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = RunnerState(s)
case string:
*e = RunnerState(s)
default:
return fmt.Errorf("unsupported scan type for RunnerState: %T", src)
}
return nil
}
type NullRunnerState struct {
RunnerState RunnerState
Valid bool // Valid is true if RunnerState is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullRunnerState) Scan(value interface{}) error {
if value == nil {
ns.RunnerState, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.RunnerState.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullRunnerState) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.RunnerState), nil
}
type Artefact struct {
ID int64
CreatedAt time.Time
Digest []byte
Content []byte
}
type Controller struct {
ID int64
Key model.ControllerKey
Created time.Time
LastSeen time.Time
State ControllerState
Endpoint string
}
type Deployment struct {
ID int64
CreatedAt time.Time
ModuleID int64
Name model.DeploymentName
Schema *schema.Module
Labels []byte
MinReplicas int32
}
type DeploymentArtefact struct {
ArtefactID int64
DeploymentID int64
CreatedAt time.Time
Executable bool
Path string
}
type Event struct {
ID int64
TimeStamp time.Time
DeploymentID int64
RequestID optional.Option[int64]
Type EventType
CustomKey1 optional.Option[string]
CustomKey2 optional.Option[string]
CustomKey3 optional.Option[string]
CustomKey4 optional.Option[string]
Payload json.RawMessage
}
type IngressRoute struct {
Method string
Path string
DeploymentID int64
Module string
Verb string
}
type Module struct {
ID int64
Language string
Name string
}
type Request struct {
ID int64
Origin Origin
Name string
SourceAddr string
}
type Runner struct {
ID int64
Key Key
Created time.Time
LastSeen time.Time
ReservationTimeout NullTime
State RunnerState
Endpoint string
ModuleName optional.Option[string]
DeploymentID optional.Option[int64]
Labels []byte
}