-
Notifications
You must be signed in to change notification settings - Fork 0
/
v1.go
3759 lines (3658 loc) · 126 KB
/
v1.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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by idl2go from JSON generated by Barrister v0.1.6
package v1
import (
"fmt"
"github.com/coopernurse/barrister-go"
"reflect"
)
const BarristerVersion string = "0.1.6"
const BarristerChecksum string = "87ef9444ef9262bbe7d97cb2e46997e8"
const BarristerDateGenerated int64 = 1606767518809000000
type EventSourceType string
const (
EventSourceTypeHttp EventSourceType = "http"
EventSourceTypeCron = "cron"
EventSourceTypeSqs = "sqs"
EventSourceTypeAwsstepfunc = "awsstepfunc"
)
type StartParallelism string
const (
StartParallelismParallel StartParallelism = "parallel"
StartParallelismSeries = "series"
StartParallelismSeriesfirst = "seriesfirst"
)
type RestartOrder string
const (
RestartOrderStartstop RestartOrder = "startstop"
RestartOrderStopstart = "stopstart"
)
type ComponentStatus string
const (
ComponentStatusActive ComponentStatus = "active"
ComponentStatusStarting = "starting"
ComponentStatusStopping = "stopping"
)
type Project struct {
Name string `json:"name"`
Components []ComponentWithEventSources `json:"components"`
}
type ComponentWithEventSources struct {
Component Component `json:"component"`
EventSources []EventSourceWithStatus `json:"eventSources"`
}
type Component struct {
Name string `json:"name"`
ProjectName string `json:"projectName,omitempty"`
Environment []NameValue `json:"environment"`
MinInstances int64 `json:"minInstances,omitempty"`
MaxInstances int64 `json:"maxInstances,omitempty"`
MaxInstancesPerNode int64 `json:"maxInstancesPerNode,omitempty"`
MaxConcurrency int64 `json:"maxConcurrency"`
SoftConcurrencyLimit bool `json:"softConcurrencyLimit,omitempty"`
ScaleUpConcurrencyPct float64 `json:"scaleUpConcurrencyPct,omitempty"`
ScaleDownConcurrencyPct float64 `json:"scaleDownConcurrencyPct,omitempty"`
MaxDurationSeconds int64 `json:"maxDurationSeconds,omitempty"`
StartParallelism StartParallelism `json:"startParallelism,omitempty"`
RestartOrder RestartOrder `json:"RestartOrder,omitempty"`
Version int64 `json:"version"`
ModifiedAt int64 `json:"modifiedAt,omitempty"`
Docker *DockerComponent `json:"docker,omitempty"`
}
type DockerComponent struct {
Image string `json:"image"`
Command []string `json:"command,omitempty"`
Entrypoint []string `json:"entrypoint,omitempty"`
HttpPort int64 `json:"httpPort"`
HttpHealthCheckPath string `json:"httpHealthCheckPath"`
HttpStartHealthCheckSeconds int64 `json:"httpStartHealthCheckSeconds,omitempty"`
HttpHealthCheckSeconds int64 `json:"httpHealthCheckSeconds,omitempty"`
HttpHealthCheckMaxFailures int64 `json:"httpHealthCheckMaxFailures,omitempty"`
HealthCheckFailedCommand []string `json:"healthCheckFailedCommand,omitempty"`
IdleTimeoutSeconds int64 `json:"idleTimeoutSeconds,omitempty"`
Ports []string `json:"ports,omitempty"`
Volumes []VolumeMount `json:"volumes,omitempty"`
NetworkName string `json:"networkName,omitempty"`
LogDriver string `json:"logDriver,omitempty"`
LogDriverOptions []NameValue `json:"logDriverOptions,omitempty"`
CpuShares int64 `json:"cpuShares,omitempty"`
ReserveMemoryMiB int64 `json:"reserveMemoryMiB,omitempty"`
LimitMemoryMiB int64 `json:"limitMemoryMiB,omitempty"`
PullCommand []string `json:"pullCommand,omitempty"`
PullUsername string `json:"pullUsername,omitempty"`
PullPassword string `json:"pullPassword,omitempty"`
PullImageOnPut bool `json:"pullImageOnPut,omitempty"`
PullImageOnStart bool `json:"pullImageOnStart,omitempty"`
Dns []string `json:"dns,omitempty"`
DnsOptions []string `json:"dnsOptions,omitempty"`
DnsSearch []string `json:"dnsSearch,omitempty"`
Ulimits []string `json:"ulimits,omitempty"`
Init bool `json:"init,omitempty"`
}
type VolumeMount struct {
Type string `json:"type,omitempty"`
Source string `json:"source"`
Target string `json:"target"`
ReadOnly bool `json:"readOnly,omitempty"`
}
type EventSourceWithStatus struct {
EventSource EventSource `json:"eventSource"`
Enabled bool `json:"enabled"`
}
type EventSource struct {
Name string `json:"name"`
ComponentName string `json:"componentName"`
ProjectName string `json:"projectName,omitempty"`
Version int64 `json:"version"`
ModifiedAt int64 `json:"modifiedAt"`
Http *HttpEventSource `json:"http,omitempty"`
Cron *CronEventSource `json:"cron,omitempty"`
Sqs *SqsEventSource `json:"sqs,omitempty"`
Awsstepfunc *AwsStepFunctionEventSource `json:"awsstepfunc,omitempty"`
}
type HttpEventSource struct {
Hostname string `json:"hostname,omitempty"`
PathPrefix string `json:"pathPrefix,omitempty"`
StripPrefix bool `json:"stripPrefix,omitempty"`
}
type CronEventSource struct {
Schedule string `json:"schedule"`
Http CronHttpRequest `json:"http"`
}
type CronHttpRequest struct {
Method string `json:"method"`
Path string `json:"path"`
Data string `json:"data,omitempty"`
Headers []NameValue `json:"headers,omitempty"`
}
type SqsEventSource struct {
QueueName string `json:"queueName"`
NameAsPrefix bool `json:"nameAsPrefix,omitempty"`
Path string `json:"path"`
MaxConcurrency int64 `json:"maxConcurrency,omitempty"`
MessagesPerPoll int64 `json:"messagesPerPoll,omitempty"`
ConcurrencyPerPoller int64 `json:"concurrencyPerPoller,omitempty"`
VisibilityTimeout int64 `json:"visibilityTimeout,omitempty"`
}
type AwsStepFunctionEventSource struct {
ActivityName string `json:"activityName"`
Path string `json:"path"`
MaxConcurrency int64 `json:"maxConcurrency,omitempty"`
ConcurrencyPerPoller int64 `json:"concurrencyPerPoller,omitempty"`
}
type NodeStatus struct {
NodeId string `json:"nodeId"`
StartedAt int64 `json:"startedAt"`
ObservedAt int64 `json:"observedAt"`
Version int64 `json:"version"`
PeerUrl string `json:"peerUrl"`
TotalMemoryMiB int64 `json:"totalMemoryMiB"`
FreeMemoryMiB int64 `json:"freeMemoryMiB"`
NumCPUs int64 `json:"numCPUs"`
LoadAvg1m float64 `json:"loadAvg1m"`
LoadAvg5m float64 `json:"loadAvg5m"`
LoadAvg15m float64 `json:"loadAvg15m"`
RunningComponents []ComponentInfo `json:"runningComponents"`
}
type ComponentInfo struct {
ComponentName string `json:"componentName"`
ComponentVersion int64 `json:"componentVersion"`
Status ComponentStatus `json:"status"`
MaxConcurrency int64 `json:"maxConcurrency"`
MemoryReservedMiB int64 `json:"memoryReservedMiB"`
StartTime int64 `json:"startTime"`
LastRequestTime int64 `json:"lastRequestTime"`
TotalRequests int64 `json:"totalRequests"`
Activity []ComponentActivity `json:"activity"`
}
type ComponentActivity struct {
Requests int64 `json:"requests"`
Concurrency float64 `json:"concurrency"`
}
type ProjectInfo struct {
ProjectName string `json:"projectName"`
ComponentCount int64 `json:"componentCount"`
EventSourceCount int64 `json:"eventSourceCount"`
}
type ListProjectsInput struct {
NamePrefix string `json:"namePrefix,omitempty"`
}
type ListProjectsOutput struct {
Projects []ProjectInfo `json:"projects"`
}
type PutProjectInput struct {
Project Project `json:"project"`
DiffOnly bool `json:"diffOnly,omitempty"`
}
type PutProjectOutput struct {
Name string `json:"name"`
ComponentsAdded []Component `json:"componentsAdded"`
ComponentsUpdated []Component `json:"componentsUpdated"`
ComponentsRemoved []string `json:"componentsRemoved"`
EventSourcesAdded []EventSource `json:"eventSourcesAdded"`
EventSourcesUpdated []EventSource `json:"eventSourcesUpdated"`
EventSourcesRemoved []string `json:"eventSourcesRemoved"`
}
type GetProjectInput struct {
Name string `json:"name"`
}
type GetProjectOutput struct {
Project Project `json:"project"`
}
type RemoveProjectInput struct {
Name string `json:"name"`
}
type RemoveProjectOutput struct {
Name string `json:"name"`
Found bool `json:"found"`
}
type RemoveComponentInput struct {
Name string `json:"name"`
}
type RemoveComponentOutput struct {
Name string `json:"name"`
Found bool `json:"found"`
}
type ListComponentsInput struct {
NamePrefix string `json:"namePrefix,omitempty"`
ProjectName string `json:"projectName,omitempty"`
Limit int64 `json:"limit,omitempty"`
NextToken string `json:"nextToken,omitempty"`
}
type ListComponentsOutput struct {
Components []Component `json:"components"`
NextToken string `json:"nextToken,omitempty"`
}
type GetComponentInput struct {
Name string `json:"name"`
}
type GetComponentOutput struct {
Component Component `json:"component"`
}
type PutComponentInput struct {
Component Component `json:"component"`
}
type PutComponentOutput struct {
Name string `json:"name"`
Version int64 `json:"version"`
}
type NotifyDataChangedInput struct {
NodeId string `json:"nodeId"`
Changes []DataChangedUnion `json:"changes"`
}
type NotifyDataChangedOutput struct {
RespondingNodeId string `json:"respondingNodeId"`
}
type DataChangedUnion struct {
PutComponent *Component `json:"putComponent,omitempty"`
RemoveComponent *RemoveComponentOutput `json:"removeComponent,omitempty"`
}
type PutEventSourceInput struct {
EventSource EventSource `json:"eventSource"`
}
type PutEventSourceOutput struct {
Name string `json:"name"`
Version int64 `json:"version"`
}
type GetEventSourceInput struct {
Name string `json:"name"`
}
type GetEventSourceOutput struct {
EventSource EventSource `json:"eventSource"`
}
type RemoveEventSourceInput struct {
Name string `json:"name"`
}
type RemoveEventSourceOutput struct {
Name string `json:"name"`
Found bool `json:"found"`
}
type ToggleEventSourcesInput struct {
Enabled bool `json:"enabled"`
NamePrefix string `json:"namePrefix,omitempty"`
ComponentName string `json:"componentName,omitempty"`
ProjectName string `json:"projectName,omitempty"`
EventSourceType EventSourceType `json:"eventSourceType,omitempty"`
}
type ToggleEventSourcesOutput struct {
Enabled bool `json:"enabled"`
EventSourceNames []string `json:"eventSourceNames"`
}
type ListEventSourcesInput struct {
NamePrefix string `json:"namePrefix,omitempty"`
ComponentName string `json:"componentName,omitempty"`
ProjectName string `json:"projectName,omitempty"`
EventSourceType EventSourceType `json:"eventSourceType,omitempty"`
Limit int64 `json:"limit,omitempty"`
NextToken string `json:"nextToken,omitempty"`
}
type ListEventSourcesOutput struct {
EventSources []EventSourceWithStatus `json:"eventSources"`
NextToken string `json:"nextToken,omitempty"`
}
type ListNodeStatusInput struct {
ForceRefresh bool `json:"forceRefresh,omitempty"`
}
type ListNodeStatusOutput struct {
RespondingNodeId string `json:"respondingNodeId"`
Nodes []NodeStatus `json:"nodes"`
}
type GetNodeStatusInput struct {
Status *NodeStatus `json:"status,omitempty"`
}
type GetNodeStatusOutput struct {
Status NodeStatus `json:"status"`
}
type StatusChangedInput struct {
NodeId string `json:"nodeId"`
Exiting bool `json:"exiting"`
Status *NodeStatus `json:"status,omitempty"`
}
type StatusChangedOutput struct {
NodeId string `json:"nodeId"`
}
type PlaceComponentInput struct {
ComponentName string `json:"componentName"`
}
type PlaceComponentOutput struct {
ComponentName string `json:"componentName"`
Node NodeStatus `json:"node"`
}
type StartStopComponentsInput struct {
ClientNodeId string `json:"clientNodeId"`
TargetVersion int64 `json:"targetVersion"`
TargetCounts []ComponentTarget `json:"targetCounts"`
ReturnStatus bool `json:"returnStatus,omitempty"`
Block bool `json:"block,omitempty"`
}
type StartStopComponentsOutput struct {
TargetVersionMismatch bool `json:"targetVersionMismatch"`
TargetStatus *NodeStatus `json:"targetStatus,omitempty"`
Started []ComponentDelta `json:"started"`
Stopped []ComponentDelta `json:"stopped"`
Errors []ComponentDeltaError `json:"errors"`
}
type TerminateNodeInput struct {
AwsLifecycleHook *AwsLifecycleHook `json:"awsLifecycleHook,omitempty"`
}
type TerminateNodeOutput struct {
AcceptedMessage bool `json:"acceptedMessage"`
NodeId string `json:"nodeId,omitempty"`
InstanceId string `json:"instanceId,omitempty"`
}
type AwsLifecycleHook struct {
QueueUrl string `json:"QueueUrl"`
MessageReceiptHandle string `json:"MessageReceiptHandle"`
AutoScalingGroupName string `json:"AutoScalingGroupName"`
InstanceId string `json:"InstanceId"`
LifecycleActionToken string `json:"LifecycleActionToken"`
LifecycleHookName string `json:"LifecycleHookName"`
}
type ComponentDelta struct {
ComponentName string `json:"componentName"`
Delta int64 `json:"delta"`
RequiredMemoryMiB int64 `json:"requiredMemoryMiB"`
}
type ComponentTarget struct {
ComponentName string `json:"componentName"`
RequiredMemoryMiB int64 `json:"requiredMemoryMiB"`
TargetCount int64 `json:"targetCount"`
}
type ComponentDeltaError struct {
ComponentDelta ComponentDelta `json:"componentDelta"`
Error string `json:"error"`
}
type NameValue struct {
Name string `json:"name"`
Value string `json:"value"`
}
type MaelstromService interface {
ListProjects(input ListProjectsInput) (ListProjectsOutput, error)
PutProject(input PutProjectInput) (PutProjectOutput, error)
GetProject(input GetProjectInput) (GetProjectOutput, error)
RemoveProject(input RemoveProjectInput) (RemoveProjectOutput, error)
PutComponent(input PutComponentInput) (PutComponentOutput, error)
GetComponent(input GetComponentInput) (GetComponentOutput, error)
RemoveComponent(input RemoveComponentInput) (RemoveComponentOutput, error)
ListComponents(input ListComponentsInput) (ListComponentsOutput, error)
PutEventSource(input PutEventSourceInput) (PutEventSourceOutput, error)
GetEventSource(input GetEventSourceInput) (GetEventSourceOutput, error)
RemoveEventSource(input RemoveEventSourceInput) (RemoveEventSourceOutput, error)
ToggleEventSources(input ToggleEventSourcesInput) (ToggleEventSourcesOutput, error)
ListEventSources(input ListEventSourcesInput) (ListEventSourcesOutput, error)
NotifyDataChanged(input NotifyDataChangedInput) (NotifyDataChangedOutput, error)
}
func NewMaelstromServiceProxy(c barrister.Client) MaelstromService {
return MaelstromServiceProxy{c, barrister.MustParseIdlJson([]byte(IdlJsonRaw))}
}
type MaelstromServiceProxy struct {
client barrister.Client
idl *barrister.Idl
}
func (_p MaelstromServiceProxy) ListProjects(input ListProjectsInput) (ListProjectsOutput, error) {
_res, _err := _p.client.Call("MaelstromService.ListProjects", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.ListProjects").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(ListProjectsOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(ListProjectsOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.ListProjects returned invalid type: %v", _t)
return ListProjectsOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return ListProjectsOutput{}, _err
}
func (_p MaelstromServiceProxy) PutProject(input PutProjectInput) (PutProjectOutput, error) {
_res, _err := _p.client.Call("MaelstromService.PutProject", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.PutProject").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(PutProjectOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(PutProjectOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.PutProject returned invalid type: %v", _t)
return PutProjectOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return PutProjectOutput{}, _err
}
func (_p MaelstromServiceProxy) GetProject(input GetProjectInput) (GetProjectOutput, error) {
_res, _err := _p.client.Call("MaelstromService.GetProject", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.GetProject").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(GetProjectOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(GetProjectOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.GetProject returned invalid type: %v", _t)
return GetProjectOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return GetProjectOutput{}, _err
}
func (_p MaelstromServiceProxy) RemoveProject(input RemoveProjectInput) (RemoveProjectOutput, error) {
_res, _err := _p.client.Call("MaelstromService.RemoveProject", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.RemoveProject").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(RemoveProjectOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(RemoveProjectOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.RemoveProject returned invalid type: %v", _t)
return RemoveProjectOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return RemoveProjectOutput{}, _err
}
func (_p MaelstromServiceProxy) PutComponent(input PutComponentInput) (PutComponentOutput, error) {
_res, _err := _p.client.Call("MaelstromService.PutComponent", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.PutComponent").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(PutComponentOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(PutComponentOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.PutComponent returned invalid type: %v", _t)
return PutComponentOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return PutComponentOutput{}, _err
}
func (_p MaelstromServiceProxy) GetComponent(input GetComponentInput) (GetComponentOutput, error) {
_res, _err := _p.client.Call("MaelstromService.GetComponent", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.GetComponent").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(GetComponentOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(GetComponentOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.GetComponent returned invalid type: %v", _t)
return GetComponentOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return GetComponentOutput{}, _err
}
func (_p MaelstromServiceProxy) RemoveComponent(input RemoveComponentInput) (RemoveComponentOutput, error) {
_res, _err := _p.client.Call("MaelstromService.RemoveComponent", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.RemoveComponent").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(RemoveComponentOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(RemoveComponentOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.RemoveComponent returned invalid type: %v", _t)
return RemoveComponentOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return RemoveComponentOutput{}, _err
}
func (_p MaelstromServiceProxy) ListComponents(input ListComponentsInput) (ListComponentsOutput, error) {
_res, _err := _p.client.Call("MaelstromService.ListComponents", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.ListComponents").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(ListComponentsOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(ListComponentsOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.ListComponents returned invalid type: %v", _t)
return ListComponentsOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return ListComponentsOutput{}, _err
}
func (_p MaelstromServiceProxy) PutEventSource(input PutEventSourceInput) (PutEventSourceOutput, error) {
_res, _err := _p.client.Call("MaelstromService.PutEventSource", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.PutEventSource").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(PutEventSourceOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(PutEventSourceOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.PutEventSource returned invalid type: %v", _t)
return PutEventSourceOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return PutEventSourceOutput{}, _err
}
func (_p MaelstromServiceProxy) GetEventSource(input GetEventSourceInput) (GetEventSourceOutput, error) {
_res, _err := _p.client.Call("MaelstromService.GetEventSource", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.GetEventSource").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(GetEventSourceOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(GetEventSourceOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.GetEventSource returned invalid type: %v", _t)
return GetEventSourceOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return GetEventSourceOutput{}, _err
}
func (_p MaelstromServiceProxy) RemoveEventSource(input RemoveEventSourceInput) (RemoveEventSourceOutput, error) {
_res, _err := _p.client.Call("MaelstromService.RemoveEventSource", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.RemoveEventSource").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(RemoveEventSourceOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(RemoveEventSourceOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.RemoveEventSource returned invalid type: %v", _t)
return RemoveEventSourceOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return RemoveEventSourceOutput{}, _err
}
func (_p MaelstromServiceProxy) ToggleEventSources(input ToggleEventSourcesInput) (ToggleEventSourcesOutput, error) {
_res, _err := _p.client.Call("MaelstromService.ToggleEventSources", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.ToggleEventSources").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(ToggleEventSourcesOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(ToggleEventSourcesOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.ToggleEventSources returned invalid type: %v", _t)
return ToggleEventSourcesOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return ToggleEventSourcesOutput{}, _err
}
func (_p MaelstromServiceProxy) ListEventSources(input ListEventSourcesInput) (ListEventSourcesOutput, error) {
_res, _err := _p.client.Call("MaelstromService.ListEventSources", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.ListEventSources").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(ListEventSourcesOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(ListEventSourcesOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.ListEventSources returned invalid type: %v", _t)
return ListEventSourcesOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return ListEventSourcesOutput{}, _err
}
func (_p MaelstromServiceProxy) NotifyDataChanged(input NotifyDataChangedInput) (NotifyDataChangedOutput, error) {
_res, _err := _p.client.Call("MaelstromService.NotifyDataChanged", input)
if _err == nil {
_retType := _p.idl.Method("MaelstromService.NotifyDataChanged").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(NotifyDataChangedOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(NotifyDataChangedOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("MaelstromService.NotifyDataChanged returned invalid type: %v", _t)
return NotifyDataChangedOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return NotifyDataChangedOutput{}, _err
}
type NodeService interface {
ListNodeStatus(input ListNodeStatusInput) (ListNodeStatusOutput, error)
GetStatus(input GetNodeStatusInput) (GetNodeStatusOutput, error)
StatusChanged(input StatusChangedInput) (StatusChangedOutput, error)
PlaceComponent(input PlaceComponentInput) (PlaceComponentOutput, error)
StartStopComponents(input StartStopComponentsInput) (StartStopComponentsOutput, error)
TerminateNode(input TerminateNodeInput) (TerminateNodeOutput, error)
}
func NewNodeServiceProxy(c barrister.Client) NodeService {
return NodeServiceProxy{c, barrister.MustParseIdlJson([]byte(IdlJsonRaw))}
}
type NodeServiceProxy struct {
client barrister.Client
idl *barrister.Idl
}
func (_p NodeServiceProxy) ListNodeStatus(input ListNodeStatusInput) (ListNodeStatusOutput, error) {
_res, _err := _p.client.Call("NodeService.ListNodeStatus", input)
if _err == nil {
_retType := _p.idl.Method("NodeService.ListNodeStatus").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(ListNodeStatusOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(ListNodeStatusOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("NodeService.ListNodeStatus returned invalid type: %v", _t)
return ListNodeStatusOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return ListNodeStatusOutput{}, _err
}
func (_p NodeServiceProxy) GetStatus(input GetNodeStatusInput) (GetNodeStatusOutput, error) {
_res, _err := _p.client.Call("NodeService.GetStatus", input)
if _err == nil {
_retType := _p.idl.Method("NodeService.GetStatus").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(GetNodeStatusOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(GetNodeStatusOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("NodeService.GetStatus returned invalid type: %v", _t)
return GetNodeStatusOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return GetNodeStatusOutput{}, _err
}
func (_p NodeServiceProxy) StatusChanged(input StatusChangedInput) (StatusChangedOutput, error) {
_res, _err := _p.client.Call("NodeService.StatusChanged", input)
if _err == nil {
_retType := _p.idl.Method("NodeService.StatusChanged").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(StatusChangedOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(StatusChangedOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("NodeService.StatusChanged returned invalid type: %v", _t)
return StatusChangedOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return StatusChangedOutput{}, _err
}
func (_p NodeServiceProxy) PlaceComponent(input PlaceComponentInput) (PlaceComponentOutput, error) {
_res, _err := _p.client.Call("NodeService.PlaceComponent", input)
if _err == nil {
_retType := _p.idl.Method("NodeService.PlaceComponent").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(PlaceComponentOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(PlaceComponentOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("NodeService.PlaceComponent returned invalid type: %v", _t)
return PlaceComponentOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return PlaceComponentOutput{}, _err
}
func (_p NodeServiceProxy) StartStopComponents(input StartStopComponentsInput) (StartStopComponentsOutput, error) {
_res, _err := _p.client.Call("NodeService.StartStopComponents", input)
if _err == nil {
_retType := _p.idl.Method("NodeService.StartStopComponents").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(StartStopComponentsOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(StartStopComponentsOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("NodeService.StartStopComponents returned invalid type: %v", _t)
return StartStopComponentsOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return StartStopComponentsOutput{}, _err
}
func (_p NodeServiceProxy) TerminateNode(input TerminateNodeInput) (TerminateNodeOutput, error) {
_res, _err := _p.client.Call("NodeService.TerminateNode", input)
if _err == nil {
_retType := _p.idl.Method("NodeService.TerminateNode").Returns
_res, _err = barrister.Convert(_p.idl, &_retType, reflect.TypeOf(TerminateNodeOutput{}), _res, "")
}
if _err == nil {
_cast, _ok := _res.(TerminateNodeOutput)
if !_ok {
_t := reflect.TypeOf(_res)
_msg := fmt.Sprintf("NodeService.TerminateNode returned invalid type: %v", _t)
return TerminateNodeOutput{}, &barrister.JsonRpcError{Code: -32000, Message: _msg}
}
return _cast, nil
}
return TerminateNodeOutput{}, _err
}
func NewJSONServer(idl *barrister.Idl, forceASCII bool, maelstromservice MaelstromService, nodeservice NodeService) barrister.Server {
return NewServer(idl, &barrister.JsonSerializer{forceASCII}, maelstromservice, nodeservice)
}
func NewServer(idl *barrister.Idl, ser barrister.Serializer, maelstromservice MaelstromService, nodeservice NodeService) barrister.Server {
_svr := barrister.NewServer(idl, ser)
_svr.AddHandler("MaelstromService", maelstromservice)
_svr.AddHandler("NodeService", nodeservice)
return _svr
}
var IdlJsonRaw = `[
{
"type": "comment",
"name": "",
"comment": "",
"value": "maelstrom.idl: Interface definition for\nhttps://maelstromapp.com/",
"extends": "",
"fields": null,
"values": null,
"functions": null,
"barrister_version": "",
"date_generated": 0,
"checksum": ""
},
{
"type": "comment",
"name": "",
"comment": "",
"value": "Generic error codes:\n\n* 1001 - Invalid value (one or more fields has an invalid value)\n* 1002 - Already exists (uniqueness constraint violated)\n* 1003 - Not found (entity with provided ID was not found)\n* 1004 - Concurrent write violation (previous version of entity is not current)\n",
"extends": "",
"fields": null,
"values": null,
"functions": null,
"barrister_version": "",
"date_generated": 0,
"checksum": ""
},
{
"type": "interface",
"name": "MaelstromService",
"comment": "MaelstromService manages the core data structures (projects, components, event sources)\ndefined by the system users",
"value": "",
"extends": "",
"fields": null,
"values": null,
"functions": [
{
"name": "ListProjects",
"comment": "ListProjects returns a paginated list of projects registered in the system.\n\nIf no projects exist in the system, ListProjectsOutput.projects\nwill be an empty list.\n\nResults are sorted by project name (ascending)\n",
"params": [
{
"name": "input",
"type": "ListProjectsInput",
"optional": false,
"is_array": false,
"comment": ""
}
],
"returns": {
"name": "",
"type": "ListProjectsOutput",
"optional": false,
"is_array": false,
"comment": ""
}
},
{
"name": "PutProject",
"comment": "PutProject registers a set of components and event sources, grouped under a single name\nThis call diffs the input project with the prior state of the project, updating components\nin the project that already exist, adding components that do not, and removing components\nassociated with the project name that are no longer present in the input project.\n\nValidation is performed before any state changes are made. If invalid input is detected\nno changes to the system will occur.\n\nError Codes:\n\n* 1001 - input.name is invalid\n* 1001 - input.components is empty\n* 1001 - input.components contains an invalid component or event source\n",
"params": [
{
"name": "input",
"type": "PutProjectInput",
"optional": false,
"is_array": false,
"comment": ""
}
],
"returns": {
"name": "",
"type": "PutProjectOutput",
"optional": false,
"is_array": false,
"comment": ""
}
},
{
"name": "GetProject",
"comment": "GetProject returns the project with the given name\n\nError Codes:\n\n* 1003 - No project found with that name\n",
"params": [
{
"name": "input",
"type": "GetProjectInput",
"optional": false,
"is_array": false,
"comment": ""
}
],
"returns": {
"name": "",
"type": "GetProjectOutput",
"optional": false,
"is_array": false,
"comment": ""
}
},
{
"name": "RemoveProject",
"comment": "RemoveProject deletes the project with the given name\n\nThis operation removes the components and event sources contained\nin the project.\n\nIf no project is found with that name no error is raised\nand the call silently no-ops.\n",
"params": [
{
"name": "input",
"type": "RemoveProjectInput",
"optional": false,
"is_array": false,
"comment": ""
}
],
"returns": {
"name": "",
"type": "RemoveProjectOutput",
"optional": false,
"is_array": false,
"comment": ""
}
},
{
"name": "PutComponent",
"comment": "PutComponent registers a component definition\n\nError Codes:\n\n* 1001 - input.name is invalid\n* 1004 - input.previousVersion does not match the version in the database\n",
"params": [
{
"name": "input",
"type": "PutComponentInput",
"optional": false,
"is_array": false,
"comment": ""
}
],
"returns": {
"name": "",
"type": "PutComponentOutput",
"optional": false,
"is_array": false,
"comment": ""
}
},
{
"name": "GetComponent",
"comment": "GetComponent returns the component with the given name\n\nError Codes:\n\n* 1003 - No component found with that name\n",
"params": [
{
"name": "input",
"type": "GetComponentInput",
"optional": false,
"is_array": false,