Skip to content

Commit 9b910e4

Browse files
Merge pull request #152 from SpineEventEngine/annotate-protobuf
Annotate Protobuf via SPI and internal
2 parents ddc3237 + 8ebedda commit 9b910e4

File tree

10 files changed

+70
-8
lines changed

10 files changed

+70
-8
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ allprojects {
1515
apply plugin: 'jacoco'
1616

1717
group = 'org.spine3'
18-
version = '0.4.2-SNAPSHOT'
18+
version = '0.4.2'
1919
}
2020

2121
project.ext {

client/src/main/proto/spine/annotations.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,8 @@ extend google.protobuf.FileOptions {
105105
// See more info in `annotations.proto`.
106106
bool beta_all = 58011;
107107
}
108+
109+
extend google.protobuf.ServiceOptions {
110+
// Indicates that the service is a part of Service Provider Interface (SPI).
111+
bool SPI_service = 58012;
112+
}

client/src/main/proto/spine/validate.proto

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//
2020
syntax = "proto3";
2121

22-
// We do not define the package for this file to allow shorter options for user-defined types.
22+
// We do not define a package for this file to allow shorter options for user-defined types.
2323
// This would allow to write:
2424
//
2525
// [(required).value = true];
@@ -34,8 +34,12 @@ option java_multiple_files = true;
3434
option java_outer_classname = "ValidationProto";
3535
option java_package = "org.spine3.validate.internal";
3636

37+
option (internal_all) = true;
38+
3739
import "google/protobuf/descriptor.proto";
3840

41+
import "spine/annotations.proto";
42+
3943
// TODO:2016-02-18:alexander.litus: obtain globally unique field number(s) for opts from Google.
4044

4145
// A type of an entity.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2016, TeamDev Ltd. All rights reserved.
3+
*
4+
* Redistribution and use in source and/or binary forms, with or without
5+
* modification, must retain the above copyright notice and the following
6+
* disclaimer.
7+
*
8+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
9+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
13+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
16+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
18+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19+
*/
20+
21+
/**
22+
* Classes and interfaces generated from gRPC service definitions into this package are
23+
* a part of Service Provider Interface (SPI) of the framework. As such they are not
24+
* supposed to be used by code of applications.
25+
*/
26+
27+
@SPI
28+
@ParametersAreNonnullByDefault
29+
package org.spine3.server.event.grpc;
30+
31+
import org.spine3.SPI;
32+
33+
import javax.annotation.ParametersAreNonnullByDefault;

server/src/main/proto/spine/server/aggregate/snapshot.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ option java_package = "org.spine3.server.aggregate";
2828

2929
import public "google/protobuf/any.proto";
3030
import public "google/protobuf/timestamp.proto";
31+
import "spine/annotations.proto";
3132

3233
// Built-in event type for storing aggregate snapshots.
3334
message Snapshot {
35+
option (SPI_type) = true;
36+
3437
// The state of the aggregate.
3538
google.protobuf.Any state = 1;
3639

server/src/main/proto/spine/server/event/event_store.proto

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,20 @@ package spine.server.event;
2424
option java_generate_equals_and_hash = true;
2525
option java_multiple_files = true;
2626
option java_outer_classname = "EventStoreProto";
27-
// Put under the 'grpc' sub-package, which is @Internal.
27+
28+
// Put generated code under the 'grpc' sub-package, which is annotated @SPI.
2829
option java_package = "org.spine3.server.event.grpc";
2930

30-
import public "spine/base/event.proto";
31-
import public "spine/base/response.proto";
31+
import "spine/annotations.proto";
32+
import "spine/base/event.proto";
33+
import "spine/base/response.proto";
3234

33-
import public "spine/server/event/event_stream_query.proto";
35+
import "spine/server/event/event_stream_query.proto";
3436

3537
// `EventStore` service allows to store events and read them via streams.
3638
service EventStore {
39+
option (SPI_service) = true;
40+
3741
// Request to append events to the storage.
3842
rpc Append(base.Event) returns (base.Response);
3943

server/src/main/proto/spine/server/storage/aggregate_storage.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ option java_outer_classname = "AggregateStorageProto";
2626
option java_multiple_files = true;
2727
option java_generate_equals_and_hash = true;
2828

29+
option (SPI_all) = true;
30+
2931
import public "spine/server/aggregate/snapshot.proto";
3032
import public "spine/base/event.proto";
33+
import "spine/annotations.proto";
3134

3235
// A record in the storage of events and snapshots of an aggregate type.
3336
//

server/src/main/proto/spine/server/storage/command_storage.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ option java_multiple_files = true;
2626
option java_outer_classname = "CommandStoreProto";
2727
option java_generate_equals_and_hash = true;
2828

29+
option (SPI_all) = true;
30+
2931
import "google/protobuf/timestamp.proto";
3032
import "google/protobuf/any.proto";
3133

3234
import "spine/base/command.proto";
3335
import "spine/base/error.proto";
3436
import "spine/base/failure.proto";
37+
import "spine/annotations.proto";
3538

3639
// This type defines the way commands are stored in command storage.
3740
// Some of the fields are defined as string representation of corresponding message types

server/src/main/proto/spine/server/storage/entity_storage.proto

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ option java_multiple_files = true;
2626
option java_outer_classname = "EntityStorageProto";
2727
option java_package = "org.spine3.server.storage";
2828

29-
import public "google/protobuf/timestamp.proto";
30-
import public "google/protobuf/any.proto";
29+
option (SPI_all) = true;
30+
31+
import "google/protobuf/timestamp.proto";
32+
import "google/protobuf/any.proto";
33+
34+
import "spine/annotations.proto";
3135

3236
// Used to store entities in the entity storage.
3337
message EntityStorageRecord {

server/src/main/proto/spine/server/storage/event_storage.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,13 @@ option java_multiple_files = true;
2626
option java_outer_classname = "EventStorageProto";
2727
option java_generate_equals_and_hash = true;
2828

29+
option (SPI_all) = true;
30+
2931
import "google/protobuf/any.proto";
3032
import "google/protobuf/timestamp.proto";
3133

3234
import "spine/base/event.proto";
35+
import "spine/annotations.proto";
3336

3437
// This type defines the way events are stored in event storage.
3538
// Some of the fields are defined as string representation of corresponding message types

0 commit comments

Comments
 (0)