Skip to content

Commit fcd720b

Browse files
refactor(protoc): better naming on broadcast options in protogen
1 parent 3703fe1 commit fcd720b

19 files changed

+458
-316
lines changed

broadcastTypes.go

+28-1
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,42 @@ func WithSubset(srvAddrs ...string) BroadcastOption {
119119
}
120120
}
121121

122-
func WithGossip(percentage float32) BroadcastOption {
122+
func WithGossip(percentage float32, ttl int) BroadcastOption {
123123
return func(b *BroadcastOptions) {
124124
b.GossipPercentage = percentage
125+
b.TTL = ttl
126+
}
127+
}
128+
129+
func WithTTL(ttl int) BroadcastOption {
130+
return func(b *BroadcastOptions) {
131+
b.TTL = ttl
132+
}
133+
}
134+
135+
func WithDeadline(deadline time.Time) BroadcastOption {
136+
return func(b *BroadcastOptions) {
137+
b.Deadline = deadline
138+
}
139+
}
140+
141+
func WithoutSelf() BroadcastOption {
142+
return func(b *BroadcastOptions) {
143+
b.SkipSelf = true
144+
}
145+
}
146+
147+
func WithoutUniquenessChecks() BroadcastOption {
148+
return func(b *BroadcastOptions) {
149+
b.OmitUniquenessChecks = true
125150
}
126151
}
127152

128153
type BroadcastOptions struct {
129154
ServerAddresses []string
130155
GossipPercentage float32
156+
TTL int
157+
Deadline time.Time
131158
OmitUniquenessChecks bool
132159
SkipSelf bool
133160
}

cmd/protoc-gen-gorums/dev/zorums.pb.go

+94-85
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/protoc-gen-gorums/dev/zorums.proto

+35-10
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,50 @@ service ZorumsService {
5959
option (gorums.quorumcall) = true;
6060
}
6161

62-
// Multiparty with QuorumCall.
63-
rpc Multiparty(Request) returns (Response) {
62+
// QuorumCall with broadcast option enables the server handler to broadcast.
63+
// The handler still works like a regular QuorumCall from the client's
64+
// perpective.
65+
rpc QuorumCallWithBroadcast(Request) returns (Response) {
6466
option (gorums.quorumcall) = true;
6567
option (gorums.broadcast) = true;
6668
}
6769

68-
// Multiparty, internal handler.
69-
rpc MultipartyInternal(Request) returns (google.protobuf.Empty) {
70+
// An rpc method with only the broadcast option specified will create a
71+
// server handler which can be used to broadcast. The handler will not
72+
// be exposed to the client, only to server. Hence, it is named internal.
73+
rpc BroadcastInternal(Request) returns (google.protobuf.Empty) {
7074
option (gorums.broadcast) = true;
7175
}
7276

73-
// Multiparty, send to client handler.
74-
rpc MultipartyClientHandler(Request) returns (Response) {
75-
option (gorums.broadcastrequest) = true;
77+
// The BroadcastCall is similar to a QuorumCall, but it enables the servers
78+
// to send the response to a client-side server handler. I.e. the client
79+
// needs to register a client-side server and register it.
80+
//
81+
// NOTE: this will NOT create a broadcast method, meaning servers cannot
82+
// call this method (only clients)
83+
rpc BroadcastWithClientHandler1(Request) returns (Response) {
84+
option (gorums.broadcastcall) = true;
7685
}
7786

78-
// Multiparty, send to client handler.
79-
rpc MultipartyClientHandler2(Request) returns (ClientResponse) {
80-
option (gorums.broadcastrequest) = true;
87+
// The BroadcastCall is similar to a QuorumCall, but it enables the servers
88+
// to send the response to a client-side server handler. I.e. the client
89+
// needs to register a client-side server and register it.
90+
//
91+
// NOTE: this will NOT create a broadcast method, meaning servers cannot
92+
// call this method (only clients)
93+
rpc BroadcastWithClientHandler2(Request) returns (ClientResponse) {
94+
option (gorums.broadcastcall) = true;
95+
}
96+
97+
// The BroadcastCall is similar to a QuorumCall, but it enables the servers
98+
// to send the response to a client-side server handler. I.e. the client
99+
// needs to register a client-side server and register it.
100+
//
101+
// NOTE: this WILL create a broadcast method, meaning servers (and clients)
102+
// can call this method
103+
rpc BroadcastWithClientHandlerAndBroadcastOption(Request) returns (ClientResponse) {
104+
option (gorums.broadcastcall) = true;
105+
option (gorums.broadcast) = true;
81106
}
82107

83108
// ------------------------------------------------------------------

cmd/protoc-gen-gorums/dev/zorums_broadcast_gorums.pb.go

+12-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/protoc-gen-gorums/dev/zorums_broadcastcall_gorums.pb.go

+198
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)