-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
2,314 additions
and
277 deletions.
There are no files selected for viewing
414 changes: 293 additions & 121 deletions
414
codegen/core/src/main/scala/com/lightbend/akkasls/codegen/ModelBuilder.scala
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+14.4 KB
...st/resources/test-files/codegen-annotation/descriptor-sets/action-shoppingcart-named.desc
Binary file not shown.
Binary file added
BIN
+14.4 KB
...src/test/resources/test-files/codegen-annotation/descriptor-sets/action-shoppingcart.desc
Binary file not shown.
Binary file added
BIN
+15.5 KB
...ces/test-files/codegen-annotation/descriptor-sets/event-sourced-shoppingcart-unnamed.desc
Binary file not shown.
Binary file added
BIN
+15.5 KB
...t/resources/test-files/codegen-annotation/descriptor-sets/event-sourced-shoppingcart.desc
Binary file not shown.
Binary file added
BIN
+15.3 KB
...ources/test-files/codegen-annotation/descriptor-sets/replicated-shoppingcart-unnamed.desc
Binary file not shown.
Binary file added
BIN
+15.3 KB
...test/resources/test-files/codegen-annotation/descriptor-sets/replicated-shoppingcart.desc
Binary file not shown.
Binary file added
BIN
+15.6 KB
...t/resources/test-files/codegen-annotation/descriptor-sets/value-shoppingcart-unnamed.desc
Binary file not shown.
Binary file added
BIN
+15.6 KB
.../src/test/resources/test-files/codegen-annotation/descriptor-sets/value-shoppingcart.desc
Binary file not shown.
Binary file added
BIN
+15.5 KB
...test/resources/test-files/codegen-annotation/descriptor-sets/view-shoppingcart-named.desc
Binary file not shown.
Binary file added
BIN
+15.5 KB
...e/src/test/resources/test-files/codegen-annotation/descriptor-sets/view-shoppingcart.desc
Binary file not shown.
107 changes: 107 additions & 0 deletions
107
codegen/core/src/test/resources/test-files/codegen-annotation/generate-from-samples.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# Re-generates sample proto file descriptors from the source | ||
# Requires https://github.com/lightbend/akkaserverless-java-sdk to be cloned locally, and its path provided | ||
# Usage: ./generate-from-samples.sh /path/to/akkaserverless-framework /path/to/akkaserverless-java-sdk | ||
|
||
if [ $# -lt 1 ]; then | ||
echo "Required arguments not supplied" | ||
echo "Usage: ./generate-from-samples.sh /path/to/akkaserverless-framework" | ||
exit 1 | ||
fi | ||
|
||
if [ ! -d "$1" ]; then | ||
echo "$1 does not exist or is not a directory" | ||
exit 1 | ||
fi | ||
|
||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/event-sourced-entity-unnamed" \ | ||
--descriptor_set_out=descriptor-sets/event-sourced-shoppingcart-unnamed.desc \ | ||
"protos/event-sourced-entity-unnamed/com/example/shoppingcart/domain/shoppingcart_domain.proto" \ | ||
"protos/event-sourced-entity-unnamed/com/example/shoppingcart/shoppingcart_api.proto" | ||
|
||
echo "Generated event-sourced-shoppingcart-unnamed.desc" | ||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/event-sourced-entity" \ | ||
--descriptor_set_out=descriptor-sets/event-sourced-shoppingcart.desc \ | ||
"protos/event-sourced-entity/com/example/shoppingcart/domain/shoppingcart_domain.proto" \ | ||
"protos/event-sourced-entity/com/example/shoppingcart/shoppingcart_api.proto" | ||
|
||
echo "Generated event-sourced-shoppingcart.desc" | ||
|
||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/view" \ | ||
--descriptor_set_out=descriptor-sets/view-shoppingcart.desc \ | ||
"protos/view/com/example/shoppingcart/view/shopping_cart_view_model.proto" | ||
|
||
echo "Generated view-shoppingcart.desc" | ||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/view-named" \ | ||
--descriptor_set_out=descriptor-sets/view-shoppingcart-named.desc \ | ||
"protos/view-named/com/example/shoppingcart/view/shopping_cart_view_model.proto" | ||
|
||
echo "Generated view-shoppingcart-named.desc" | ||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/value-entity-unnamed" \ | ||
--descriptor_set_out=descriptor-sets/value-shoppingcart-unnamed.desc \ | ||
"protos/value-entity-unnamed/com/example/shoppingcart/domain/shoppingcart_domain.proto" \ | ||
"protos/value-entity-unnamed/com/example/shoppingcart/shoppingcart_api.proto" | ||
|
||
echo "Generated value-shoppingcart-unnamed.desc" | ||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/value-entity" \ | ||
--descriptor_set_out=descriptor-sets/value-shoppingcart.desc \ | ||
"protos/value-entity/com/example/shoppingcart/domain/shoppingcart_domain.proto" \ | ||
"protos/value-entity/com/example/shoppingcart/shoppingcart_api.proto" | ||
|
||
echo "Generated value-shoppingcart.desc" | ||
|
||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/action" \ | ||
--descriptor_set_out=descriptor-sets/action-shoppingcart.desc \ | ||
"protos/action/com/example/shoppingcart/shoppingcart_controller_api.proto" | ||
|
||
echo "Generated action-shoppingcart.desc" | ||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/action-named" \ | ||
--descriptor_set_out=descriptor-sets/action-shoppingcart-named.desc \ | ||
"protos/action-named/com/example/shoppingcart/shoppingcart_controller_api.proto" | ||
|
||
echo "Generated action-shoppingcart.desc" | ||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/replicated-entity-unnamed" \ | ||
--descriptor_set_out=descriptor-sets/replicated-shoppingcart-unnamed.desc \ | ||
"protos/replicated-entity-unnamed/com/example/shoppingcart/domain/shoppingcart_domain.proto" \ | ||
"protos/replicated-entity-unnamed/com/example/shoppingcart/shoppingcart_api.proto" | ||
|
||
echo "Generated replicated-shoppingcart-unnamed.desc" | ||
|
||
protoc --include_imports \ | ||
--proto_path="$1/protocols/sdk/src/main/protobuf" \ | ||
--proto_path="protos/replicated-entity" \ | ||
--descriptor_set_out=descriptor-sets/replicated-shoppingcart.desc \ | ||
"protos/replicated-entity/com/example/shoppingcart/domain/shoppingcart_domain.proto" \ | ||
"protos/replicated-entity/com/example/shoppingcart/shoppingcart_api.proto" | ||
|
||
echo "Generated replicated-shoppingcart.desc" |
39 changes: 39 additions & 0 deletions
39
...annotation/protos/action-named/com/example/shoppingcart/shoppingcart_controller_api.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021 Lightbend Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package com.example.shoppingcart; | ||
|
||
option java_outer_classname = "ShoppingCartController"; | ||
import "akkaserverless/annotations.proto"; | ||
|
||
message NewCart { | ||
} | ||
|
||
message NewCartCreated { | ||
string cart_id = 1; | ||
} | ||
|
||
service ShoppingCartAction { | ||
option (akkaserverless.codegen) = { | ||
action: { | ||
name: ".controllers.ShoppingCartController" | ||
} | ||
}; | ||
|
||
rpc InitializeCart(NewCart) returns (NewCartCreated); | ||
rpc CreatePrePopulated(NewCart) returns (NewCartCreated); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...degen-annotation/protos/action/com/example/shoppingcart/shoppingcart_controller_api.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2021 Lightbend Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package com.example.shoppingcart; | ||
|
||
option java_outer_classname = "ShoppingCartController"; | ||
import "akkaserverless/annotations.proto"; | ||
|
||
message NewCart { | ||
} | ||
|
||
message NewCartCreated { | ||
string cart_id = 1; | ||
} | ||
|
||
service ShoppingCartAction { | ||
option (akkaserverless.codegen) = { | ||
action: { } | ||
}; | ||
|
||
rpc InitializeCart(NewCart) returns (NewCartCreated); | ||
rpc CreatePrePopulated(NewCart) returns (NewCartCreated); | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...os/event-sourced-entity-unnamed/com/example/shoppingcart/domain/shoppingcart_domain.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2021 Lightbend Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package com.example.shoppingcart.domain; | ||
option java_outer_classname = "ShoppingCartDomain"; | ||
|
||
message LineItem { | ||
string productId = 1; | ||
string name = 2; | ||
int32 quantity = 3; | ||
} | ||
|
||
// The item added event. | ||
message ItemAdded { | ||
LineItem item = 1; | ||
} | ||
|
||
// The item removed event. | ||
message ItemRemoved { | ||
string productId = 1; | ||
} | ||
|
||
// The checked out event. | ||
message CheckedOut { | ||
int64 checked_out_timestamp = 1; | ||
} | ||
|
||
// The shopping cart state. | ||
message Cart { | ||
repeated LineItem items = 1; | ||
} | ||
// end::domain[] |
66 changes: 66 additions & 0 deletions
66
...ation/protos/event-sourced-entity-unnamed/com/example/shoppingcart/shoppingcart_api.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2021 Lightbend Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package com.example.shoppingcart; | ||
|
||
import "akkaserverless/annotations.proto"; | ||
import "google/protobuf/empty.proto"; | ||
|
||
option java_outer_classname = "ShoppingCartApi"; | ||
|
||
message AddLineItem { | ||
string cart_id = 1 [(akkaserverless.field).entity_key = true]; | ||
string product_id = 2; | ||
string name = 3; | ||
int32 quantity = 4; | ||
} | ||
|
||
message RemoveLineItem { | ||
string cart_id = 1 [(akkaserverless.field).entity_key = true]; | ||
string product_id = 2; | ||
} | ||
|
||
message GetShoppingCart { | ||
string cart_id = 1 [(akkaserverless.field).entity_key = true]; | ||
} | ||
|
||
message LineItem { | ||
string product_id = 1; | ||
string name = 2; | ||
int32 quantity = 3; | ||
} | ||
|
||
message Cart { | ||
repeated LineItem items = 1; | ||
} | ||
|
||
service ShoppingCartService { | ||
option (akkaserverless.codegen) = { | ||
event_sourced_entity: { | ||
entity_type: "shopping-cart" | ||
state: ".domain.Cart" | ||
events: [ | ||
".domain.ItemAdded", | ||
".domain.ItemRemoved" ] | ||
} | ||
}; | ||
|
||
rpc AddItem (AddLineItem) returns (google.protobuf.Empty); | ||
|
||
rpc RemoveItem (RemoveLineItem) returns (google.protobuf.Empty); | ||
|
||
rpc GetCart (GetShoppingCart) returns (Cart); | ||
} |
45 changes: 45 additions & 0 deletions
45
...ion/protos/event-sourced-entity/com/example/shoppingcart/domain/shoppingcart_domain.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2021 Lightbend Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
syntax = "proto3"; | ||
|
||
package com.example.shoppingcart.domain; | ||
option java_outer_classname = "ShoppingCartDomain"; | ||
|
||
message LineItem { | ||
string productId = 1; | ||
string name = 2; | ||
int32 quantity = 3; | ||
} | ||
|
||
// The item added event. | ||
message ItemAdded { | ||
LineItem item = 1; | ||
} | ||
|
||
// The item removed event. | ||
message ItemRemoved { | ||
string productId = 1; | ||
} | ||
|
||
// The checked out event. | ||
message CheckedOut { | ||
int64 checked_out_timestamp = 1; | ||
} | ||
|
||
// The shopping cart state. | ||
message Cart { | ||
repeated LineItem items = 1; | ||
} | ||
// end::domain[] |
Oops, something went wrong.