Skip to content

Commit

Permalink
feat: introduce verb visibility modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Apr 25, 2024
1 parent 7b70ba9 commit d8a7858
Show file tree
Hide file tree
Showing 45 changed files with 463 additions and 411 deletions.
34 changes: 22 additions & 12 deletions backend/protos/xyz/block/ftl/v1/schema/schema.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions backend/protos/xyz/block/ftl/v1/schema/schema.proto
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ message Verb {

optional Position pos = 1;
string name = 2;
repeated string comments = 3;
Type request = 4;
Type response = 5;
repeated Metadata metadata = 6;
string visibility = 3;

Check failure on line 265 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "3" with name "visibility" on message "Verb" changed option "json_name" from "comments" to "visibility".

Check failure on line 265 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "3" on message "Verb" changed label from "repeated" to "optional".

Check failure on line 265 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "3" on message "Verb" changed name from "comments" to "visibility".
repeated string comments = 4;

Check failure on line 266 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "4" with name "comments" on message "Verb" changed option "json_name" from "request" to "comments".

Check failure on line 266 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "4" on message "Verb" changed label from "optional" to "repeated".

Check failure on line 266 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "4" on message "Verb" changed type from "message" to "string".

Check failure on line 266 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "4" on message "Verb" changed name from "request" to "comments".
Type request = 5;

Check failure on line 267 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "5" with name "request" on message "Verb" changed option "json_name" from "response" to "request".

Check failure on line 267 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "5" on message "Verb" changed name from "response" to "request".
Type response = 6;

Check failure on line 268 in backend/protos/xyz/block/ftl/v1/schema/schema.proto

View workflow job for this annotation

GitHub Actions / Proto Breaking Change Check

Field "6" with name "response" on message "Verb" changed option "json_name" from "metadata" to "response".
repeated Metadata metadata = 7;
}
53 changes: 29 additions & 24 deletions backend/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ module todo {
when Time
}
verb create(todo.CreateRequest) todo.CreateResponse
internal verb create(todo.CreateRequest) todo.CreateResponse
+calls todo.destroy +database calls todo.testdb
verb destroy(builtin.HttpRequest<todo.DestroyRequest>) builtin.HttpResponse<todo.DestroyResponse, String>
public verb destroy(builtin.HttpRequest<todo.DestroyRequest>) builtin.HttpResponse<todo.DestroyResponse, String>
+ingress http GET /todo/destroy/{name}
verb scheduled(Unit) Unit
internal verb scheduled(Unit) Unit
+cron */10 * * 1-10,11-31 * * *
}
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestParsing(t *testing.T) {
data CreateListResponse {}
// Create a new list
verb createList(todo.CreateListRequest) todo.CreateListResponse
internal verb createList(todo.CreateListRequest) todo.CreateListResponse
+calls todo.createList
}
`,
Expand All @@ -198,9 +198,10 @@ func TestParsing(t *testing.T) {
&Data{Name: "CreateListRequest"},
&Data{Name: "CreateListResponse"},
&Verb{Name: "createList",
Comments: []string{"Create a new list"},
Request: &Ref{Module: "todo", Name: "CreateListRequest"},
Response: &Ref{Module: "todo", Name: "CreateListResponse"},
Visibility: "internal",
Comments: []string{"Create a new list"},
Request: &Ref{Module: "todo", Name: "CreateListRequest"},
Response: &Ref{Module: "todo", Name: "CreateListResponse"},
Metadata: []Metadata{
&MetadataCalls{Calls: []*Ref{{Module: "todo", Name: "createList"}}},
},
Expand All @@ -210,10 +211,10 @@ func TestParsing(t *testing.T) {
},
}},
{name: "InvalidRequestRef",
input: `module test { verb test(InvalidRequest) InvalidResponse}`,
input: `module test { internal verb test(InvalidRequest) InvalidResponse}`,
errors: []string{
"1:25-25: unknown reference \"InvalidRequest\"",
"1:41-41: unknown reference \"InvalidResponse\""}},
"1:34-34: unknown reference \"InvalidRequest\"",
"1:50-50: unknown reference \"InvalidResponse\""}},
{name: "InvalidRef",
input: `module test { data Data { user user.User }}`,
errors: []string{
Expand All @@ -231,18 +232,19 @@ func TestParsing(t *testing.T) {
"1:35-35: unknown reference \"verb\"",
}},
{name: "KeywordAsName",
input: `module int { data String { name String } verb verb(String) String }`,
input: `module int { data String { name String } internal verb verb(String) String }`,
errors: []string{"1:14-14: data structure name \"String\" is a reserved word"}},
{name: "BuiltinRef",
input: `module test { verb myIngress(HttpRequest<String>) HttpResponse<String, String> }`,
input: `module test { public verb myIngress(HttpRequest<String>) HttpResponse<String, String> }`,
expected: &Schema{
Modules: []*Module{{
Name: "test",
Decls: []Decl{
&Verb{
Name: "myIngress",
Request: &Ref{Module: "builtin", Name: "HttpRequest", TypeParameters: []Type{&String{}}},
Response: &Ref{Module: "builtin", Name: "HttpResponse", TypeParameters: []Type{&String{}, &String{}}},
Name: "myIngress",
Visibility: "public",
Request: &Ref{Module: "builtin", Name: "HttpRequest", TypeParameters: []Type{&String{}}},
Response: &Ref{Module: "builtin", Name: "HttpResponse", TypeParameters: []Type{&String{}, &String{}}},
},
},
}},
Expand Down Expand Up @@ -401,11 +403,11 @@ module todo {
name String
when Time
}
verb create(todo.CreateRequest) todo.CreateResponse
internal verb create(todo.CreateRequest) todo.CreateResponse
+calls todo.destroy +database calls todo.testdb
verb destroy(builtin.HttpRequest<todo.DestroyRequest>) builtin.HttpResponse<todo.DestroyResponse, String>
public verb destroy(builtin.HttpRequest<todo.DestroyRequest>) builtin.HttpResponse<todo.DestroyResponse, String>
+ingress http GET /todo/destroy/{name}
verb scheduled(Unit) Unit
internal verb scheduled(Unit) Unit
+cron */10 * * 1-10,11-31 * * *
}
`
Expand Down Expand Up @@ -486,15 +488,17 @@ var testSchema = MustValidate(&Schema{
},
},
&Verb{Name: "create",
Request: &Ref{Module: "todo", Name: "CreateRequest"},
Response: &Ref{Module: "todo", Name: "CreateResponse"},
Visibility: "internal",
Request: &Ref{Module: "todo", Name: "CreateRequest"},
Response: &Ref{Module: "todo", Name: "CreateResponse"},
Metadata: []Metadata{
&MetadataCalls{Calls: []*Ref{{Module: "todo", Name: "destroy"}}},
&MetadataDatabases{Calls: []*Ref{{Module: "todo", Name: "testdb"}}},
}},
&Verb{Name: "destroy",
Request: &Ref{Module: "builtin", Name: "HttpRequest", TypeParameters: []Type{&Ref{Module: "todo", Name: "DestroyRequest"}}},
Response: &Ref{Module: "builtin", Name: "HttpResponse", TypeParameters: []Type{&Ref{Module: "todo", Name: "DestroyResponse"}, &String{}}},
Visibility: "public",
Request: &Ref{Module: "builtin", Name: "HttpRequest", TypeParameters: []Type{&Ref{Module: "todo", Name: "DestroyRequest"}}},
Response: &Ref{Module: "builtin", Name: "HttpResponse", TypeParameters: []Type{&Ref{Module: "todo", Name: "DestroyResponse"}, &String{}}},
Metadata: []Metadata{
&MetadataIngress{
Type: "http",
Expand All @@ -508,8 +512,9 @@ var testSchema = MustValidate(&Schema{
},
},
&Verb{Name: "scheduled",
Request: &Unit{Unit: true},
Response: &Unit{Unit: true},
Visibility: "internal",
Request: &Unit{Unit: true},
Response: &Unit{Unit: true},
Metadata: []Metadata{
&MetadataCronJob{
Cron: "*/10 * * 1-10,11-31 * * *",
Expand Down
Loading

0 comments on commit d8a7858

Please sign in to comment.