Skip to content

Commit

Permalink
Move proto files to /protocol (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergekh2 authored May 22, 2024
1 parent e697d9f commit 3dec3e9
Show file tree
Hide file tree
Showing 19 changed files with 996 additions and 979 deletions.
5 changes: 4 additions & 1 deletion core/node/protocol/buf.yaml → buf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
version: v1
version: v2
modules:
- path: protocol
- path: core/proto
breaking:
use:
- FILE
Expand Down
2 changes: 1 addition & 1 deletion core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

brew install protobuf@3
brew link --overwrite protobuf@3
brew install bufbuild/buf/buf
go install github.com/bufbuild/buf/cmd/buf@latest

There are addition install steps for go tools in [./node/README.md](./node/README.md)

Expand Down
9 changes: 8 additions & 1 deletion core/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ Run

or manually:

# Proto
go install github.com/bufbuild/buf/cmd/buf@latest
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest

# GRPC helper
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest

# Lint
go install honnef.co/go/tools/cmd/staticcheck@latest

# Format
go install mvdan.cc/gofumpt@latest
go install github.com/segmentio/golines@latest

Expand Down
4 changes: 0 additions & 4 deletions core/node/events/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ func Make_MemberPayload_DisplayName(displayName *EncryptedData) *StreamEvent_Mem
func Make_ChannelPayload_Inception(
streamId StreamId,
spaceId StreamId,
channelProperties *EncryptedData,
settings *StreamSettings,
) *StreamEvent_ChannelPayload {
return &StreamEvent_ChannelPayload{
Expand All @@ -174,7 +173,6 @@ func Make_ChannelPayload_Inception(
Inception: &ChannelPayload_Inception{
StreamId: streamId[:],
SpaceId: spaceId[:],
ChannelProperties: channelProperties,
Settings: settings,
},
},
Expand Down Expand Up @@ -285,7 +283,6 @@ func Make_SpacePayload_Membership(op MembershipOp, userId string, initiatorId st
func Make_SpacePayload_Channel(
op ChannelOp,
channelId StreamId,
channelProperties *EncryptedData,
originEvent *EventRef,
) *StreamEvent_SpacePayload {
return &StreamEvent_SpacePayload{
Expand All @@ -295,7 +292,6 @@ func Make_SpacePayload_Channel(
Op: op,
ChannelId: channelId[:],
OriginEvent: originEvent,
ChannelProperties: channelProperties,
},
},
},
Expand Down
11 changes: 2 additions & 9 deletions core/node/events/stream_viewstate_space_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,19 @@ func makeTestChannelStream(
userId string,
channelStreamId StreamId,
spaceSpaceId StreamId,
channelProperties *protocol.EncryptedData,
streamSettings *protocol.StreamSettings,
) ([]*ParsedEvent, *protocol.Miniblock) {
if streamSettings == nil {
streamSettings = &protocol.StreamSettings{
DisableMiniblockCreation: true,
}
}
if channelProperties == nil {
channelProperties = &protocol.EncryptedData{
Ciphertext: "encrypted text supposed to be here",
}
}
inception := makeEnvelopeWithPayload_T(
t,
wallet,
Make_ChannelPayload_Inception(
channelStreamId,
spaceSpaceId,
channelProperties,
streamSettings,
),
nil,
Expand Down Expand Up @@ -319,7 +312,7 @@ func TestChannelViewState_JoinedMembers(t *testing.T) {
spaceStream := sStream.(*streamImpl)
joinSpace_T(t, userWallet, ctx, spaceStream, []string{bob, carol})
// create a channel stream and add the members
_, mb = makeTestChannelStream(t, userWallet, alice, channelStreamId, spaceStreamId, nil, nil)
_, mb = makeTestChannelStream(t, userWallet, alice, channelStreamId, spaceStreamId, nil)
cStream, _, _ := tt.createStream(ctx, channelStreamId, mb)
channelStream := cStream.(*streamImpl)
joinChannel_T(t, userWallet, ctx, channelStream, []string{alice, bob, carol})
Expand Down Expand Up @@ -375,7 +368,7 @@ func TestChannelViewState_RemainingMembers(t *testing.T) {
spaceStream := sStream.(*streamImpl)
joinSpace_T(t, userWallet, ctx, spaceStream, []string{bob, carol})
// create a channel stream and add the members
_, mb = makeTestChannelStream(t, userWallet, alice, channelStreamId, spaceStreamId, nil, nil)
_, mb = makeTestChannelStream(t, userWallet, alice, channelStreamId, spaceStreamId, nil)
cStream, _, err := tt.createStream(ctx, channelStreamId, mb)
require.NoError(t, err)
channelStream := cStream.(*streamImpl)
Expand Down
12 changes: 7 additions & 5 deletions core/node/protocol/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
version: v1
version: v2
plugins:
- name: go
out: .
- remote: buf.build/protocolbuffers/go:v1.34.1
out: core/node/protocol
opt: paths=source_relative
- name: connect-go
out: .
- remote: buf.build/connectrpc/go:v1.16.2
out: core/node/protocol
opt: paths=source_relative
inputs:
- directory: protocol
24 changes: 3 additions & 21 deletions core/node/protocol/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,9 @@ cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")"
[ -n "$(go env GOBIN)" ] && PATH="$(go env GOBIN):${PATH}"
[ -n "$(go env GOPATH)" ] && PATH="$(go env GOPATH)/bin:${PATH}"

KEEP_PROTO=false

# Use "-k" to keep protocol.proto to simplify development.
while getopts "k" opt; do
case $opt in
k)
KEEP_PROTO=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done

cp ../../proto/protocol.proto .
buf generate --path protocol.proto --path internode.proto

if [ "$KEEP_PROTO" = false ]; then
rm protocol.proto
fi
pushd ../../.. > /dev/null
buf generate --template core/node/protocol/buf.gen.yaml --path protocol/protocol.proto --path protocol/internode.proto
popd > /dev/null

cd ../protocol_extensions
go run main.go
2 changes: 1 addition & 1 deletion core/node/protocol/internode.pb.go

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

Loading

0 comments on commit 3dec3e9

Please sign in to comment.