Skip to content

Commit

Permalink
feat: event-sourcing compliant berty protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
glouvigny committed Dec 20, 2019
1 parent 5753167 commit da9507f
Show file tree
Hide file tree
Showing 18 changed files with 2,824 additions and 5,653 deletions.
595 changes: 192 additions & 403 deletions api/bertyprotocol.proto

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/gen.sum

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

836 changes: 296 additions & 540 deletions docs/protocol/api.md

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions go/framework/bpbridge/bridge_test.go
Expand Up @@ -29,7 +29,7 @@ func TestBridge(t *testing.T) {
bridgeClient *Client
grpcClient *grpc.ClientConn
req, res []byte
results [][]byte
//results [][]byte
)

logger := testutil.Logger(t)
Expand Down Expand Up @@ -62,37 +62,37 @@ func TestBridge(t *testing.T) {
checkErr(t, err)

// setup unary test
msg := &bertyprotocol.ContactGet_Request{}
msg := &bertyprotocol.InstanceGetConfiguration_Request{}

req, err = proto.Marshal(msg)
checkErr(t, err)

// bridgeClient test
res, err = bridgeClient.UnaryRequest("/berty.protocol.ProtocolService/ContactGet", req)
res, err = bridgeClient.UnaryRequest("/berty.protocol.ProtocolService/InstanceGetConfiguration", req)
checkErr(t, err)

out := &bertyprotocol.ContactGet_Reply{}
out := &bertyprotocol.InstanceGetConfiguration_Reply{}
err = proto.Unmarshal(res, out)
checkErr(t, err)

// webclient test
cc := bertyprotocol.NewProtocolServiceClient(grpcClient)
_, err = cc.ContactGet(context.Background(), msg)
_, err = cc.InstanceGetConfiguration(context.Background(), msg)
checkErr(t, err)

results, err = makeGrpcRequest(
bridge.GRPCWebListenerAddr(),
"/berty.protocol.ProtocolService/ContactGet",
[][]byte{req},
false,
)
checkErr(t, err)

for _, res = range results {
out := &bertyprotocol.ContactGet_Reply{}
err = proto.Unmarshal(res, out)
checkErr(t, err)
}
//results, err = makeGrpcRequest(
// bridge.GRPCWebListenerAddr(),
// "/berty.protocol.ProtocolService/ContactGet",
// [][]byte{req},
// false,
//)
//checkErr(t, err)
//
//for _, res = range results {
// out := &bertyprotocol.InstanceGetConfiguration{}
// err = proto.Unmarshal(res, out)
// checkErr(t, err)
//}
}

func makeRequest(host string, method string, headers http.Header, body io.Reader, isText bool) (*http.Response, error) {
Expand Down
2 changes: 1 addition & 1 deletion go/gen.sum

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

31 changes: 0 additions & 31 deletions go/pkg/bertyprotocol/api_account.go

This file was deleted.

11 changes: 11 additions & 0 deletions go/pkg/bertyprotocol/api_app.go
@@ -0,0 +1,11 @@
package bertyprotocol

import (
"context"

"berty.tech/go/pkg/errcode"
)

func (c *client) AccountAppendAppSpecificEvent(context.Context, *AccountAppendAppSpecificEvent_Request) (*AccountAppendAppSpecificEvent_Reply, error) {
return nil, errcode.ErrNotImplemented
}
14 changes: 8 additions & 6 deletions go/pkg/bertyprotocol/api_contact.go
Expand Up @@ -6,15 +6,17 @@ import (
"berty.tech/go/pkg/errcode"
)

func (c *client) ContactGet(ctx context.Context, in *ContactGet_Request) (*ContactGet_Reply, error) {
ret := &ContactGet_Reply{}
return ret, nil
// ContactRemove removes a contact
func (c *client) ContactRemove(context.Context, *ContactRemove_Request) (*ContactRemove_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) ContactList(*ContactList_Request, ProtocolService_ContactListServer) error {
return errcode.ErrNotImplemented
// ContactBlock blocks a contact, stops advertising on its rendezvous point
func (c *client) ContactBlock(context.Context, *ContactBlock_Request) (*ContactBlock_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) ContactRemove(context.Context, *ContactRemove_Request) (*ContactRemove_Reply, error) {
// ContactUnblock unblocks a contact, resumes advertising on its rendezvous point
func (c *client) ContactUnblock(context.Context, *ContactUnblock_Request) (*ContactUnblock_Reply, error) {
return nil, errcode.ErrNotImplemented
}
24 changes: 17 additions & 7 deletions go/pkg/bertyprotocol/api_contactrequest.go
Expand Up @@ -6,22 +6,32 @@ import (
"berty.tech/go/pkg/errcode"
)

func (c *client) ContactRequestAccept(context.Context, *ContactRequestAccept_Request) (*ContactRequestAccept_Reply, error) {
// ContactRequestReference retrieves the necessary information to create a contact link
func (c *client) ContactRequestReference(context.Context, *ContactRequestReference_Request) (*ContactRequestReference_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) ContactRequestDiscard(context.Context, *ContactRequestDiscard_Request) (*ContactRequestDiscard_Reply, error) {
// ContactRequestDisable disables incoming contact requests
func (c *client) ContactRequestDisable(context.Context, *ContactRequestDisable_Request) (*ContactRequestDisable_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) ContactRequestListIncoming(*ContactRequestListIncoming_Request, ProtocolService_ContactRequestListIncomingServer) error {
return errcode.ErrNotImplemented
// ContactRequestEnable enables incoming contact requests
func (c *client) ContactRequestEnable(context.Context, *ContactRequestEnable_Request) (*ContactRequestEnable_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) ContactRequestListOutgoing(*ContactRequestListOutgoing_Request, ProtocolService_ContactRequestListOutgoingServer) error {
return errcode.ErrNotImplemented
// ContactRequestResetReference generates a new contact request reference
func (c *client) ContactRequestResetReference(context.Context, *ContactRequestResetLink_Request) (*ContactRequestResetLink_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) ContactRequestSend(context.Context, *ContactRequestSend_Request) (*ContactRequestSend_Reply, error) {
// ContactRequestEnqueue enqueues a new contact request to be sent
func (c *client) ContactRequestEnqueue(context.Context, *ContactRequestEnqueue_Request) (*ContactRequestEnqueue_Reply, error) {
return nil, errcode.ErrNotImplemented
}

// ContactRequestAccept accepts a contact request
func (c *client) ContactRequestAccept(context.Context, *ContactRequestAccept_Request) (*ContactRequestAccept_Reply, error) {
return nil, errcode.ErrNotImplemented
}
12 changes: 12 additions & 0 deletions go/pkg/bertyprotocol/api_device.go
@@ -0,0 +1,12 @@
package bertyprotocol

import (
"context"

"berty.tech/go/pkg/errcode"
)

// DevicePair pairs a new device to the current account
func (c *client) DevicePair(context.Context, *DevicePair_Request) (*DevicePair_Reply, error) {
return nil, errcode.ErrNotImplemented
}
18 changes: 17 additions & 1 deletion go/pkg/bertyprotocol/api_event.go
Expand Up @@ -2,6 +2,22 @@ package bertyprotocol

import "berty.tech/go/pkg/errcode"

func (c *client) EventSubscribe(*EventSubscribe_Request, ProtocolService_EventSubscribeServer) error {
// AccountSubscribe subscribes to the account events
func (c *client) AccountSubscribe(*AccountSubscribe_Request, ProtocolService_AccountSubscribeServer) error {
return errcode.ErrNotImplemented
}

// GroupSettingSubscribe subscribes to the setting events for a group
func (c *client) GroupSettingSubscribe(*GroupSettingStoreSubscribe_Request, ProtocolService_GroupSettingSubscribeServer) error {
return errcode.ErrNotImplemented
}

// GroupMessageSubscribe subscribes to the message events for a group
func (c *client) GroupMessageSubscribe(*GroupMessageSubscribe_Request, ProtocolService_GroupMessageSubscribeServer) error {
return errcode.ErrNotImplemented
}

// GroupMemberSubscribe subscribes to the member events for a group
func (c *client) GroupMemberSubscribe(*GroupMemberSubscribe_Request, ProtocolService_GroupMemberSubscribeServer) error {
return errcode.ErrNotImplemented
}
27 changes: 15 additions & 12 deletions go/pkg/bertyprotocol/api_group.go
Expand Up @@ -6,34 +6,37 @@ import (
"berty.tech/go/pkg/errcode"
)

// GroupCreate initiates a new group and joins it
func (c *client) GroupCreate(context.Context, *GroupCreate_Request) (*GroupCreate_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) GroupGenerateInviteLink(context.Context, *GroupGenerateInviteLink_Request) (*GroupGenerateInviteLink_Reply, error) {
// GroupJoin joins an existing group
func (c *client) GroupJoin(context.Context, *GroupJoin_Request) (*GroupJoin_Reply, error) {
return nil, errcode.ErrNotImplemented
}

// GroupLeave leaves a group
func (c *client) GroupLeave(context.Context, *GroupLeave_Request) (*GroupLeave_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) GroupList(*GroupList_Request, ProtocolService_GroupListServer) error {
return errcode.ErrNotImplemented
}

func (c *client) GroupMessageCreate(context.Context, *GroupMessageCreate_Request) (*GroupMessageCreate_Reply, error) {
// GroupInvite generates an invitation to a group
func (c *client) GroupInvite(context.Context, *GroupInvite_Request) (*GroupInvite_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) GroupMessageList(*GroupMessageList_Request, ProtocolService_GroupMessageListServer) error {
return errcode.ErrNotImplemented
// GroupSettingSetGroup sets a setting for a group
func (c *client) GroupSettingSetGroup(context.Context, *GroupSettingSetGroup_Request) (*GroupSettingSetGroup_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) GroupTopicPublish(ProtocolService_GroupTopicPublishServer) error {
return errcode.ErrNotImplemented
// GroupSettingSetGroup sets a setting for own group member
func (c *client) GroupSettingSetMember(context.Context, *GroupSettingSetMember_Request) (*GroupSettingSetMember_Reply, error) {
return nil, errcode.ErrNotImplemented
}

func (c *client) GroupTopicSubscribe(*GroupTopicSubscribe_Request, ProtocolService_GroupTopicSubscribeServer) error {
return errcode.ErrNotImplemented
// GroupMessageSend sends a message to the group
func (c *client) GroupMessageSend(context.Context, *GroupMessageSend_Request) (*GroupMessageSend_Reply, error) {
return nil, errcode.ErrNotImplemented
}
23 changes: 0 additions & 23 deletions go/pkg/bertyprotocol/api_groupinvitation.go

This file was deleted.

15 changes: 0 additions & 15 deletions go/pkg/bertyprotocol/api_stream.go

This file was deleted.

0 comments on commit da9507f

Please sign in to comment.