Skip to content

Commit 19769fc

Browse files
committedMar 19, 2024·
Merge branch 'master' into retry
2 parents e8aa996 + b44fc9a commit 19769fc

31 files changed

+404
-409
lines changed
 

‎.github/workflows/go-test.yml

+23-14
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,39 @@ jobs:
99
test:
1010
strategy:
1111
matrix:
12-
go-version: [1.16]
12+
go-version: ["1.22"]
1313
platform: [ubuntu-latest, macos-latest]
1414
runs-on: ${{ matrix.platform }}
15+
1516
steps:
16-
- name: Install Go
17-
uses: actions/setup-go@v2
18-
with:
19-
go-version: ${{ matrix.go-version }}
20-
- name: Install Protoc
21-
uses: arduino/setup-protoc@master
17+
- name: Cache Go Modules
18+
uses: actions/cache@v3
2219
with:
23-
version: '3.x'
24-
repo-token: ${{ secrets.GITHUB_TOKEN }}
25-
- uses: actions/cache@v2
26-
with:
27-
path: ~/go/pkg/mod
20+
path: |
21+
~/.cache/go-build # ubuntu-latest
22+
~/Library/Caches/go-build # macos-latest
23+
~/go/pkg/mod
2824
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2925
restore-keys: |
3026
${{ runner.os }}-go-
27+
3128
- name: Checkout code
32-
uses: actions/checkout@v2
29+
uses: actions/checkout@v3
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@v3
33+
with:
34+
go-version: ${{ matrix.go-version }}
35+
36+
- name: Install Protoc
37+
uses: arduino/setup-protoc@v3.0.0
38+
with:
39+
repo-token: ${{ secrets.GITHUB_TOKEN }}
40+
3341
- name: Install tools
3442
run: |
3543
make tools
3644
make installgorums
37-
- name: Test
45+
46+
- name: Run Tests
3847
run: make test

‎.github/workflows/golangci-lint.yml

+28-26
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
11
name: golangci-lint
22
on:
33
push:
4-
branches: [ master ]
4+
branches: [master]
55
pull_request:
6-
branches: [ master ]
6+
permissions:
7+
contents: read
8+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
9+
pull-requests: read
710

811
jobs:
912
golangci:
10-
strategy:
11-
matrix:
12-
go-version: [1.16]
13+
name: lint
1314
runs-on: ubuntu-latest
1415
steps:
15-
- name: Install Go
16-
uses: actions/setup-go@v2
17-
with:
18-
go-version: ${{ matrix.go-version }}
19-
20-
- name: Install Protoc
21-
uses: arduino/setup-protoc@master
22-
with:
23-
version: '3.x'
24-
repo-token: ${{ secrets.GITHUB_TOKEN }}
25-
26-
- name: Cache Go modules
27-
uses: actions/cache@v2
16+
- name: Cache Go Modules
17+
uses: actions/cache@v3
2818
with:
2919
path: |
20+
~/.cache/go-build # ubuntu-latest
21+
~/Library/Caches/go-build # macos-latest
3022
~/go/pkg/mod
31-
~/.cache/go-build
32-
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
23+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
3324
restore-keys: |
34-
${{ runner.os }}-${{ matrix.go-version }}-go-
25+
${{ runner.os }}-go-
3526
36-
- name: Checkout
37-
uses: actions/checkout@v2
27+
- name: Checkout code
28+
uses: actions/checkout@v3
29+
30+
- name: Set up Go
31+
uses: actions/setup-go@v3
32+
with:
33+
go-version: "1.22"
34+
35+
- name: Setup Protoc
36+
uses: arduino/setup-protoc@v3.0.0
37+
with:
38+
repo-token: ${{ secrets.GITHUB_TOKEN }}
3839

3940
- name: Run Make
4041
run: make
4142

4243
- name: Run golangci-lint
43-
uses: golangci/golangci-lint-action@v2
44+
uses: golangci/golangci-lint-action@v3
4445
with:
4546
version: latest
46-
skip-go-installation: true
4747
skip-pkg-cache: true
4848
skip-build-cache: true
49-
args: --disable errcheck
49+
args: --timeout 5m --disable errcheck
50+
# Optional: show only new issues if it's a pull request. The default value is `false`.
51+
only-new-issues: true

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ Session.vim
3232
*~
3333

3434
*.xo
35+
.vscode/*.log
3536

3637
# binary files
3738
cmd/benchmark/benchmark
3839

3940
ideas.txt
4041

4142
cmd/protoc-gen-gorums/gengorums/template_static.go.bak
43+
44+
# jetbrains IDE files
45+
.idea/

‎.vscode/gorums.txt

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ emptypb
1414
Erevik
1515
errcheck
1616
extendee
17+
Frausing's
1718
fset
1819
gengorums
1920
GOBIN
@@ -28,14 +29,17 @@ gorumsexample
2829
grpc
2930
Hein
3031
ICDCS
32+
Idents
3133
Idxs
34+
Iface
3235
Ingve
3336
installgorums
3437
Jehl
3538
Lmsgprefix
3639
Mallocs
3740
markdownlint
3841
mcast
42+
Meland's
3943
Meling
4044
memprofile
4145
multicast
@@ -46,12 +50,15 @@ pkgs
4650
proto
4751
protobuf
4852
protoc
53+
protogen
4954
protoimpl
55+
protoreflect
5056
ptypes
5157
QCQF
5258
qcresult
5359
qspec
5460
quorumcall
61+
Reconf
5562
relab
5663
rlevel
5764
RPC's
@@ -68,6 +75,8 @@ Tormod
6875
unexport
6976
Unexported
7077
unicast
78+
unmarshal
79+
unmarshaled
7180
unmarshaling
7281
userguide
7382
Xeon

‎channel.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,26 @@ func (c *channel) sendMsg(req request) (err error) {
118118
c.streamMut.RLock()
119119
defer c.streamMut.RUnlock()
120120

121-
done := make(chan struct{}, 1)
121+
done := make(chan struct{})
122122

123-
// wait for either the message to be sent, or the request context being cancelled.
124-
// if the request context was cancelled, then we most likely have a blocked stream.
123+
// This goroutine waits for either 'done' to be closed, or the request context to be cancelled.
124+
// If the request context was cancelled, we have two possibilities:
125+
// The stream could be blocked, or the caller could be impatient.
126+
// We cannot know which is the case, but it seems wiser to cancel the stream as a precaution,
127+
// because reconnection is quite fast and cheap.
125128
go func() {
126129
select {
127130
case <-done:
131+
// all is good
128132
case <-req.ctx.Done():
129-
c.cancelStream()
133+
// Both channels could be ready at the same time, so we should check 'done' again.
134+
select {
135+
case <-done:
136+
// false alarm
137+
default:
138+
// cause reconnect
139+
c.cancelStream()
140+
}
130141
}
131142
}()
132143

@@ -135,7 +146,8 @@ func (c *channel) sendMsg(req request) (err error) {
135146
c.setLastErr(err)
136147
c.streamBroken.set()
137148
}
138-
done <- struct{}{}
149+
150+
close(done)
139151

140152
return err
141153
}

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

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

‎cmd/protoc-gen-gorums/dev/zorums_async_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_correctable_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_multicast_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_qspec_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_quorumcall_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_rpc_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_server_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_types_gorums.pb.go

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

‎cmd/protoc-gen-gorums/dev/zorums_unicast_gorums.pb.go

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

‎cmd/protoc-gen-gorums/gengorums/gorums.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type servicesData struct {
116116
Services []*protogen.Service
117117
}
118118

119-
// genGorumsType generates Gorums methods and corresponding datastructures for gorumsType.
119+
// genGorumsType generates Gorums methods and corresponding data structures for gorumsType.
120120
func genGorumsType(g *protogen.GeneratedFile, services []*protogen.Service, gorumsType string) {
121121
data := servicesData{g, services}
122122
if callTypeInfo := gorumsCallTypesInfo[gorumsType]; callTypeInfo.extInfo == nil {
@@ -240,7 +240,7 @@ func callTypeName(ext *protoimpl.ExtensionInfo) string {
240240
// files for the different keys.
241241
var gorumsCallTypesInfo = map[string]*callTypeInfo{
242242
"qspec": {template: qspecInterface},
243-
"types": {template: datatypes},
243+
"types": {template: dataTypes},
244244
"server": {template: server},
245245

246246
callTypeName(gorums.E_Rpc): {

‎cmd/protoc-gen-gorums/gengorums/gorums_bundle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func GenerateBundleFile(dst string) {
5656
fmt.Printf("\nReview changes above; to revert use:\n")
5757
fmt.Printf("mv %s.bak %s\n", dst, dst)
5858
}
59-
err = os.WriteFile(dst, []byte(staticContent), 0666)
59+
err = os.WriteFile(dst, []byte(staticContent), 0o666)
6060
if err != nil {
6161
log.Fatal(err)
6262
}

‎cmd/protoc-gen-gorums/gengorums/template_datatypes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ func (c *{{$correctableOut}}) Get() (*{{$customOut}}, int, error) {
6161
{{- end -}}
6262
`
6363

64-
var datatypes = internalOutDataType +
64+
var dataTypes = internalOutDataType +
6565
asyncDataType +
6666
correctableDataType

‎doc/design-doc-layering.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Examples of such layers includes
1515

1616
Frausing's thesis provided two implementations of such layering, one based on interceptors and the metadata support in gRPC, and one where the layer was designed as two separate gRPC services, one with a prefix `g` to separate it from the actual service that applications should use. Please see Frausing's thesis for additional details, and his code on [GitHub](https://github.com/tfrausin/reconf). There is also a question and an answer in this [gRPC issue](https://github.com/grpc/grpc-go/issues/2091).
1717

18-
The metadata approach is not type safe because everything must be converted to a string, and in Frausing's implementation, this requires a custom marshalling and unmarshalling implementation. Moreover, it seems that there is a larger overhead with this approach compared to the alternative with using separate gRPC interfaces.
18+
The metadata approach is not type safe because everything must be converted to a string, and in Frausing's implementation, this requires a custom marshaling and unmarshaling implementation. Moreover, it seems that there is a larger overhead with this approach compared to the alternative with using separate gRPC interfaces.
1919

2020
## The interceptor approach
2121

22-
However, it would be interesting to consider (as suggested in the gRPC issue linked above) a generic implementation that will marshal/unmarshal a protobuf structure to/from a json string that can be passed as part of the metadata feature of gRPC. What do I mean by generic here? Well, the content of the metadata to be passed in the metadata structure of an RPC request/response message should be defined as a proto message type, and the marshalling functions should be automatic. Basically, the code generator should produce marshalling functions for the metadata, and a layer-specific method that accepts the request/response object and unmarshalled metadata type as generated by the protobuf for that metadata object.
22+
However, it would be interesting to consider (as suggested in the gRPC issue linked above) a generic implementation that will marshal/unmarshal a protobuf structure to/from a json string that can be passed as part of the metadata feature of gRPC. What do I mean by generic here? Well, the content of the metadata to be passed in the metadata structure of an RPC request/response message should be defined as a proto message type, and the marshaling functions should be automatic. Basically, the code generator should produce marshaling functions for the metadata, and a layer-specific method that accepts the request/response object and unmarshaled metadata type as generated by the protobuf for that metadata object.
2323

2424
We should essentially generate the interceptor code that extract things and calls out to a function like this:
2525

@@ -55,7 +55,7 @@ message Config {
5555
}
5656
```
5757

58-
Note that, we don't need to maintain two separate message types for the actual configuration (list of machines) and the epoch, since if the list of machines is empty, it won't take any space in the message. Empty fields will simply be removed during marshalling.
58+
Note that, we don't need to maintain two separate message types for the actual configuration (list of machines) and the epoch, since if the list of machines is empty, it won't take any space in the message. Empty fields will simply be removed during marshaling.
5959

6060
On the server-side, our implementation of the reconfiguration layer would look something like this:
6161

@@ -145,6 +145,6 @@ Note that the `c.cc` connection points to the reconfiguration layer's `Read` met
145145

146146
1. If our code generator produces these additional layering methods for us, do we need to register the server implementing all interfaces (both `pbm.Config` and `pb.Storage`) or can it be replaced with the top-layer only?
147147

148-
2. Can we support multiple layers? For example, if we want to support both reconfiguration and all-to-all communcation, and these features are best kept separate?
148+
2. Can we support multiple layers? For example, if we want to support both reconfiguration and all-to-all communication, and these features are best kept separate?
149149

150150
3. The approach above is not so flexible in that a new layer will probably want to define templates for code generation.

0 commit comments

Comments
 (0)