generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
models.go
492 lines (429 loc) · 10.3 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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.26.0
package sql
import (
"database/sql/driver"
"encoding/json"
"fmt"
"time"
"github.com/TBD54566975/ftl/backend/controller/leases"
"github.com/TBD54566975/ftl/backend/schema"
"github.com/TBD54566975/ftl/internal/model"
"github.com/alecthomas/types/optional"
"github.com/google/uuid"
)
type AsyncCallState string
const (
AsyncCallStatePending AsyncCallState = "pending"
AsyncCallStateExecuting AsyncCallState = "executing"
AsyncCallStateSuccess AsyncCallState = "success"
AsyncCallStateError AsyncCallState = "error"
)
func (e *AsyncCallState) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = AsyncCallState(s)
case string:
*e = AsyncCallState(s)
default:
return fmt.Errorf("unsupported scan type for AsyncCallState: %T", src)
}
return nil
}
type NullAsyncCallState struct {
AsyncCallState AsyncCallState
Valid bool // Valid is true if AsyncCallState is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAsyncCallState) Scan(value interface{}) error {
if value == nil {
ns.AsyncCallState, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AsyncCallState.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAsyncCallState) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.AsyncCallState), nil
}
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 CronJobState string
const (
CronJobStateIdle CronJobState = "idle"
CronJobStateExecuting CronJobState = "executing"
)
func (e *CronJobState) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = CronJobState(s)
case string:
*e = CronJobState(s)
default:
return fmt.Errorf("unsupported scan type for CronJobState: %T", src)
}
return nil
}
type NullCronJobState struct {
CronJobState CronJobState
Valid bool // Valid is true if CronJobState is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullCronJobState) Scan(value interface{}) error {
if value == nil {
ns.CronJobState, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.CronJobState.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullCronJobState) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.CronJobState), 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 FsmStatus string
const (
FsmStatusRunning FsmStatus = "running"
FsmStatusCompleted FsmStatus = "completed"
FsmStatusFailed FsmStatus = "failed"
)
func (e *FsmStatus) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = FsmStatus(s)
case string:
*e = FsmStatus(s)
default:
return fmt.Errorf("unsupported scan type for FsmStatus: %T", src)
}
return nil
}
type NullFsmStatus struct {
FsmStatus FsmStatus
Valid bool // Valid is true if FsmStatus is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullFsmStatus) Scan(value interface{}) error {
if value == nil {
ns.FsmStatus, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.FsmStatus.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullFsmStatus) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.FsmStatus), 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 AsyncCall struct {
ID int64
CreatedAt time.Time
LeaseID optional.Option[int64]
Verb schema.RefKey
State AsyncCallState
Origin string
ScheduledAt time.Time
Request []byte
Response []byte
Error optional.Option[string]
RemainingAttempts int32
Backoff time.Duration
MaxBackoff time.Duration
}
type Controller struct {
ID int64
Key model.ControllerKey
Created time.Time
LastSeen time.Time
State ControllerState
Endpoint string
}
type CronJob struct {
ID int64
Key model.CronJobKey
DeploymentID int64
Verb string
Schedule string
StartTime time.Time
NextExecution time.Time
State model.CronJobState
ModuleName string
}
type Deployment struct {
ID int64
CreatedAt time.Time
ModuleID int64
Key model.DeploymentKey
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 FsmInstance struct {
ID int64
CreatedAt time.Time
Fsm schema.RefKey
Key string
Status FsmStatus
CurrentState NullRef
DestinationState NullRef
AsyncCallID optional.Option[int64]
}
type IngressRoute struct {
Method string
Path string
DeploymentID int64
Module string
Verb string
}
type Lease struct {
ID int64
IdempotencyKey uuid.UUID
Key leases.Key
CreatedAt time.Time
ExpiresAt time.Time
}
type Module struct {
ID int64
Language string
Name string
}
type ModuleConfiguration struct {
ID int64
CreatedAt time.Time
Module optional.Option[string]
Name string
Value []byte
}
type Request struct {
ID int64
Origin Origin
Key model.RequestKey
SourceAddr string
}
type Runner struct {
ID int64
Key model.RunnerKey
Created time.Time
LastSeen time.Time
ReservationTimeout NullTime
State RunnerState
Endpoint string
ModuleName optional.Option[string]
DeploymentID optional.Option[int64]
Labels []byte
}
type Topic struct {
ID int64
Key model.TopicKey
CreatedAt time.Time
ModuleID int64
Name string
Type string
}
type TopicEvent struct {
ID int64
CreatedAt time.Time
Key model.TopicEventKey
TopicID int64
Payload []byte
}
type TopicSubscriber struct {
ID int64
Key model.SubscriberKey
CreatedAt time.Time
TopicSubscriptionsID int64
DeploymentID int64
Sink string
}
type TopicSubscription struct {
ID int64
Key model.SubscriptionKey
CreatedAt time.Time
TopicID int64
ModuleID int64
Name string
Cursor optional.Option[int64]
}