-
Notifications
You must be signed in to change notification settings - Fork 13
/
service.proto
206 lines (166 loc) · 5.7 KB
/
service.proto
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
syntax = "proto3";
import "gogo/protobuf/gogoproto/gogo.proto";
package service;
option go_package = "github.com/mesg-foundation/engine/service";
option (gogoproto.goproto_getters_all) = false;
// Service represents the service's type.
message Service {
// Events are emitted by the service whenever the service wants.
message Event {
// Event's key.
string key = 4 [
(gogoproto.moretags) = 'hash:"name:1" validate:"printascii"'
];
// Event's name.
string name = 1 [
(gogoproto.moretags) = 'hash:"name:2" validate:"printascii"'
];
// Event's description.
string description = 2 [
(gogoproto.moretags) = 'hash:"name:3" validate:"printascii"'
];
// List of data of this event.
repeated Parameter data = 3 [
(gogoproto.moretags) = 'hash:"name:4" validate:"dive,required"'
];
}
// Task is a function that requires inputs and returns output.
message Task {
// Task's key.
string key = 8 [
(gogoproto.moretags) = 'hash:"name:1" validate:"printascii"'
];
// Task's name.
string name = 1 [
(gogoproto.moretags) = 'hash:"name:2" validate:"printascii"'
];
// Task's description.
string description = 2 [
(gogoproto.moretags) = 'hash:"name:3" validate:"printascii"'
];
// List inputs of this task.
repeated Parameter inputs = 6 [
(gogoproto.moretags) = 'hash:"name:4" validate:"dive,required"'
];
// List of tasks outputs.
repeated Parameter outputs = 7 [
(gogoproto.moretags) = 'hash:"name:5" validate:"dive,required"'
];
}
// Parameter describes the task's inputs, the task's outputs, and the event's data.
message Parameter {
// Parameter's key.
string key = 8 [
(gogoproto.moretags) = 'hash:"name:1" validate:"printascii"'
];
// Parameter's name.
string name = 1 [
(gogoproto.moretags) = 'hash:"name:2" validate:"printascii"'
];
// Parameter's description.
string description = 2 [
(gogoproto.moretags) = 'hash:"name:3" validate:"printascii"'
];
// Parameter's type: `String`, `Number`, `Boolean`, `Object` or `Any`.
string type = 3 [
(gogoproto.moretags) = 'hash:"name:4" validate:"required,printascii,oneof=String Number Boolean Object Any"'
];
// Set the parameter as optional.
bool optional = 4 [
(gogoproto.moretags) = 'hash:"name:5"'
];
// Mark a parameter as an array of the defined type.
bool repeated = 9 [
(gogoproto.moretags) = 'hash:"name:7"'
];
// Optional object structure type when type is set to `Object`.
repeated Parameter object = 10 [
(gogoproto.moretags) = 'hash:"name:7" validate:"unique,dive,required"'
];
}
// A configuration is the configuration of the main container of the service's instance.
message Configuration {
// List of volumes.
repeated string volumes = 1 [
(gogoproto.moretags) = 'hash:"name:1" validate:"unique,dive,printascii"'
];
// List of volumes mounted from other dependencies.
repeated string volumesFrom = 2 [
(gogoproto.moretags) = 'hash:"name:2" validate:"unique,dive,printascii"'
];
// List of ports the container exposes.
repeated string ports = 3 [
(gogoproto.moretags) = 'hash:"name:3" validate:"unique,dive,portmap"'
];
// Args to pass to the container.
repeated string args = 4 [
(gogoproto.moretags) = 'hash:"name:5" validate:"printascii"'
];
// Command to run the container.
string command = 5 [
(gogoproto.moretags) = 'hash:"name:4" validate:"printascii"'
];
// Default env vars to apply to service's instance on runtime.
repeated string env = 6 [
(gogoproto.moretags) = 'hash:"name:6" validate:"unique,dive,env"'
];
}
// A dependency is a configuration of an other container that runs separately from the service.
message Dependency {
// Dependency's key.
string key = 8 [
(gogoproto.moretags) = 'hash:"name:1" validate:"printascii"'
];
// Image's name of the container.
string image = 1 [
(gogoproto.moretags) = 'hash:"name:2" validate:"printascii"'
];
// Configuration of the container.
Configuration configuration = 3 [
(gogoproto.nullable) = false
];
}
// Service's hash.
string hash = 10 [
(gogoproto.moretags) = 'validate:"required"',
(gogoproto.customtype) = "github.com/mesg-foundation/engine/hash.Hash",
(gogoproto.nullable) = false
];
// Service's sid.
string sid = 12 [
(gogoproto.moretags) = 'validate:"required,printascii,max=63,domain"'
];
// Service's name.
string name = 1 [
(gogoproto.moretags) = 'hash:"name:2" validate:"required,printascii"'
];
// Service's description.
string description = 2 [
(gogoproto.moretags) = 'hash:"name:3" validate:"printascii"'
];
// Configurations related to the service
Configuration configuration = 8 [
(gogoproto.moretags) = 'hash:"name:8" validate:"required"',
(gogoproto.nullable) = false
];
// The list of tasks this service can execute.
repeated Task tasks = 5 [
(gogoproto.moretags) = 'hash:"name:4" validate:"dive,required"'
];
// The list of events this service can emit.
repeated Event events = 6 [
(gogoproto.moretags) = 'hash:"name:5" validate:"dive,required"'
];
// The container dependencies this service requires.
repeated Dependency dependencies = 7 [
(gogoproto.moretags) = 'hash:"name:6" validate:"dive,required"'
];
// Service's repository url.
string repository = 9 [
(gogoproto.moretags) = 'hash:"name:7" validate:"omitempty,uri"'
];
// The hash id of service's source code on IPFS.
string source = 13 [
(gogoproto.moretags) = 'hash:"name:9" validate:"required,printascii"'
];
}