From d3cb4a5c9bfca013d39e7574aa1a1bf23895a582 Mon Sep 17 00:00:00 2001 From: Guilhem Fanton Date: Thu, 25 Oct 2018 18:52:09 +0200 Subject: [PATCH] feat(metrics): Add monitor bandwidth --- .../Devtools/{Network.js => Network.js.old} | 0 .../Settings/Devtools/Networks/List.js | 33 + .../Settings/Devtools/Networks/Peers.js | 43 + .../Settings/Devtools/Networks/index.js | 21 + .../Screens/Settings/Devtools/Peers.js | 43 + .../Screens/Settings/Devtools/index.js | 4 +- .../common/graphql/queries/Peers.js | 12 + .../common/graphql/queries/index.js | 1 + .../graphql/subscriptions/MonitorPeers.js | 14 + client/react-native/common/schema.graphql | 62 +- core/api/client/berty.node.service.gen.go | 18 + .../jsonclient/berty.node.service.gen.go | 125 +- core/api/node/graphql/gqlgen.gen.yml | 42 + .../node/graphql/graph/generated/generated.go | 1080 +++++++++++++++-- core/api/node/graphql/resolver.go | 49 + core/api/node/graphql/service.gen.graphql | 62 +- core/api/node/service.pb.go | 720 ++++++++--- core/api/node/service.proto | 43 +- core/go.mod | 2 +- core/network/driver.go | 19 +- core/network/p2p/driver.go | 22 + core/network/p2p/metrics.go | 87 +- core/node/p2papi.go | 32 +- 23 files changed, 2129 insertions(+), 405 deletions(-) rename client/react-native/common/components/Screens/Settings/Devtools/{Network.js => Network.js.old} (100%) create mode 100644 client/react-native/common/components/Screens/Settings/Devtools/Networks/List.js create mode 100644 client/react-native/common/components/Screens/Settings/Devtools/Networks/Peers.js create mode 100644 client/react-native/common/components/Screens/Settings/Devtools/Networks/index.js create mode 100644 client/react-native/common/components/Screens/Settings/Devtools/Peers.js create mode 100644 client/react-native/common/graphql/queries/Peers.js create mode 100644 client/react-native/common/graphql/subscriptions/MonitorPeers.js diff --git a/client/react-native/common/components/Screens/Settings/Devtools/Network.js b/client/react-native/common/components/Screens/Settings/Devtools/Network.js.old similarity index 100% rename from client/react-native/common/components/Screens/Settings/Devtools/Network.js rename to client/react-native/common/components/Screens/Settings/Devtools/Network.js.old diff --git a/client/react-native/common/components/Screens/Settings/Devtools/Networks/List.js b/client/react-native/common/components/Screens/Settings/Devtools/Networks/List.js new file mode 100644 index 0000000000..46ce0c40d1 --- /dev/null +++ b/client/react-native/common/components/Screens/Settings/Devtools/Networks/List.js @@ -0,0 +1,33 @@ +import React, { PureComponent } from 'react' +import { Header, Menu } from '../../../../Library' + +export default class List extends PureComponent { + static navigationOptions = ({ navigation }) => ({ + header: ( +
+ ), + tabBarVisible: false, + }) + + render () { + const { navigation } = this.props + return ( + + + { + navigation.push('networks/peers') + }} + /> + + + ) + } +} diff --git a/client/react-native/common/components/Screens/Settings/Devtools/Networks/Peers.js b/client/react-native/common/components/Screens/Settings/Devtools/Networks/Peers.js new file mode 100644 index 0000000000..52ee939ca8 --- /dev/null +++ b/client/react-native/common/components/Screens/Settings/Devtools/Networks/Peers.js @@ -0,0 +1,43 @@ +import React, { PureComponent } from 'react' +import { Text, View, ActivityIndicator } from 'react-native' +import { Header, Screen } from '../../../../Library' +import { QueryReducer } from '../../../../../relay' +import { queries } from '../../../../../graphql' +import { colors } from '../../../../../constants' + +export default class Peers extends PureComponent { + static navigationOptions = ({ navigation }) => ({ + header: ( +
+ ), + }) + + render () { + return ( + + + {(state, retry) => { + console.log('state:', state) + switch (state.type) { + case state.success: + return ( + + {state.data.Peers.list.map((peer, i) => ( + {peer.id} + ))} + + ) + default: + return + } + }} + + + ) + } +} diff --git a/client/react-native/common/components/Screens/Settings/Devtools/Networks/index.js b/client/react-native/common/components/Screens/Settings/Devtools/Networks/index.js new file mode 100644 index 0000000000..6b6d52c829 --- /dev/null +++ b/client/react-native/common/components/Screens/Settings/Devtools/Networks/index.js @@ -0,0 +1,21 @@ +import React from 'react' +import { createSubStackNavigator } from '../../../../../helpers/react-navigation' +import { Header } from '../../../../Library' +import List from './List' +import Peers from './Peers' + +export default createSubStackNavigator( + { + 'networks/list': List, + 'networks/peers': Peers, + }, + { + initialRouteName: 'networks/list', + navigationOptions: ({ navigation }) => ({ + header: ( +
+ ), + tabBarVisible: false, + }), + } +) diff --git a/client/react-native/common/components/Screens/Settings/Devtools/Peers.js b/client/react-native/common/components/Screens/Settings/Devtools/Peers.js new file mode 100644 index 0000000000..a149fbbc23 --- /dev/null +++ b/client/react-native/common/components/Screens/Settings/Devtools/Peers.js @@ -0,0 +1,43 @@ +import React, { PureComponent } from 'react' +import { Menu, Header } from '../../../Library' +import { mutations } from '../../../../graphql' + +export default class Database extends PureComponent { + static navigationOptions = ({ navigation }) => ({ + header: ( +
+ ), + }) + render () { + return ( + + + { + try { + await mutations.generateFakeData.commit({ t: true }) + } catch (err) { + this.setState({ err }) + console.error(err) + } + }} + /> + { + console.log('Reset') + }} + /> + + + ) + } +} diff --git a/client/react-native/common/components/Screens/Settings/Devtools/index.js b/client/react-native/common/components/Screens/Settings/Devtools/index.js index e3037781de..313bfd5375 100644 --- a/client/react-native/common/components/Screens/Settings/Devtools/index.js +++ b/client/react-native/common/components/Screens/Settings/Devtools/index.js @@ -1,7 +1,7 @@ import { createSubStackNavigator } from '../../../../helpers/react-navigation' import List from './List' import Database from './Database' -import Network from './Network' +import Networks from './Networks/index.js' import EventList from './EventList' import EventDetails from './EventDetails' import DeviceInfos from './DeviceInfos' @@ -12,7 +12,7 @@ export default createSubStackNavigator( { 'devtools/list': List, 'devtools/database': Database, - 'devtools/network': Network, + 'devtools/network': Networks, 'devtools/eventlist': EventList, 'devtools/eventdetails': EventDetails, 'devtools/deviceinfos': DeviceInfos, diff --git a/client/react-native/common/graphql/queries/Peers.js b/client/react-native/common/graphql/queries/Peers.js new file mode 100644 index 0000000000..ed7047681f --- /dev/null +++ b/client/react-native/common/graphql/queries/Peers.js @@ -0,0 +1,12 @@ +import { graphql } from 'react-relay' + +export default graphql` + query PeersListQuery { + Peers(T: true) { + list { + id + addrs + } + } + } +` diff --git a/client/react-native/common/graphql/queries/index.js b/client/react-native/common/graphql/queries/index.js index 6190eff1d1..e077c8c353 100644 --- a/client/react-native/common/graphql/queries/index.js +++ b/client/react-native/common/graphql/queries/index.js @@ -5,3 +5,4 @@ export DeviceInfos from './DeviceInfos' export AppVersion from './AppVersion' export EventList from './EventList' export Panic from './Panic' +export Peers from './Peers' diff --git a/client/react-native/common/graphql/subscriptions/MonitorPeers.js b/client/react-native/common/graphql/subscriptions/MonitorPeers.js new file mode 100644 index 0000000000..56978420fe --- /dev/null +++ b/client/react-native/common/graphql/subscriptions/MonitorPeers.js @@ -0,0 +1,14 @@ +import { graphql } from 'react-relay' +import { subscriber } from '../../relay' + +const MonitorPeers = graphql` + subscription MonitorPeersSubscription { + MonitorPeers { + id + addrs + connection + } + } +` + +export default subscriber({ subscription: MonitorPeers }) diff --git a/client/react-native/common/schema.graphql b/client/react-native/common/schema.graphql index bcd04a2d07..7db01c66c1 100644 --- a/client/react-native/common/schema.graphql +++ b/client/react-native/common/schema.graphql @@ -372,6 +372,19 @@ type BertyP2pEvent implements Node { +type BertyP2pBandwidthStats { + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum +} + + + + + type BertyP2pPeer { id: String! addrs: [String!] @@ -433,6 +446,11 @@ type BertyNodePageInfo { type BertyNodeVoid { T: Bool! } +type BertyP2pPeerPayload { + id: String! + addrs: [String!] + connection: Enum +} input BertyP2pEventInput { id: ID! senderId: String! @@ -562,23 +580,32 @@ type BertyNodeIntegrationTestPayload { startedAt: GoogleProtobufTimestamp finishedAt: GoogleProtobufTimestamp } -type BertyP2pPeerPayload { - id: String! - addrs: [String!] - connection: Enum -} -type BertyP2pPeersPayload { - list: [BertyP2pPeer] -} type BertyNodeDeviceInfosPayload { infos: [BertyNodeDeviceInfo] } type BertyNodeAppVersionPayload { version: String! } +type BertyP2pPeersPayload { + list: [BertyP2pPeer] +} +type BertyNodeProtocolsPayload { + protocols: [String!] +} +type BertyP2pBandwidthStatsPayload { + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum +} type Query { node(id: ID!): Node + ID( + T: Bool! + ): BertyP2pPeerPayload EventList( filter: BertyP2pEventInput orderBy: String! @@ -655,15 +682,20 @@ type Query { conversationId: String! contactId: String! ): BertyEntityConversationMemberPayload - Peers( - T: Bool! - ): BertyP2pPeersPayload DeviceInfos( T: Bool! ): BertyNodeDeviceInfosPayload AppVersion( T: Bool! ): BertyNodeAppVersionPayload + Peers( + T: Bool! + ): BertyP2pPeersPayload + Protocols( + id: String! + addrs: [String!] + connection: Enum + ): BertyNodeProtocolsPayload Panic( T: Bool! ): BertyNodeVoidPayload @@ -742,6 +774,14 @@ type Subscription { EventStream( filter: BertyP2pEventInput ): BertyP2pEventPayload + MonitorBandwidth( + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum + ): BertyP2pBandwidthStatsPayload MonitorPeers( T: Bool! ): BertyP2pPeerPayload diff --git a/core/api/client/berty.node.service.gen.go b/core/api/client/berty.node.service.gen.go index 67e9e03327..2948ed0f7b 100644 --- a/core/api/client/berty.node.service.gen.go +++ b/core/api/client/berty.node.service.gen.go @@ -86,6 +86,24 @@ func (c *Client) ConversationList(ctx context.Context, input *node.ConversationL } return entries, nil } +func (c *Client) MonitorBandwidth(ctx context.Context, input *p2p.BandwidthStats) ([]*p2p.BandwidthStats, error) { + stream, err := c.Node().MonitorBandwidth(ctx, input) + if err != nil { + return nil, err + } + var entries []*p2p.BandwidthStats + for { + entry, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return nil, err + } + entries = append(entries, entry) + } + return entries, nil +} func (c *Client) MonitorPeers(ctx context.Context, input *node.Void) ([]*p2p.Peer, error) { stream, err := c.Node().MonitorPeers(ctx, input) if err != nil { diff --git a/core/api/client/jsonclient/berty.node.service.gen.go b/core/api/client/jsonclient/berty.node.service.gen.go index f61177fa99..4c2a95d577 100644 --- a/core/api/client/jsonclient/berty.node.service.gen.go +++ b/core/api/client/jsonclient/berty.node.service.gen.go @@ -16,6 +16,7 @@ import ( ) func init() { + registerUnary("berty.node.ID", NodeID) registerServerStream("berty.node.EventStream", NodeEventStream) registerServerStream("berty.node.EventList", NodeEventList) registerUnary("berty.node.GetEvent", NodeGetEvent) @@ -35,14 +36,30 @@ func init() { registerUnary("berty.node.HandleEvent", NodeHandleEvent) registerUnary("berty.node.GenerateFakeData", NodeGenerateFakeData) registerUnary("berty.node.RunIntegrationTests", NodeRunIntegrationTests) - registerServerStream("berty.node.MonitorPeers", NodeMonitorPeers) - registerUnary("berty.node.Peers", NodePeers) registerUnary("berty.node.DebugPing", NodeDebugPing) registerUnary("berty.node.DeviceInfos", NodeDeviceInfos) registerUnary("berty.node.AppVersion", NodeAppVersion) + registerUnary("berty.node.Peers", NodePeers) + registerUnary("berty.node.Protocols", NodeProtocols) + registerServerStream("berty.node.MonitorBandwidth", NodeMonitorBandwidth) + registerServerStream("berty.node.MonitorPeers", NodeMonitorPeers) registerUnary("berty.node.Panic", NodePanic) } +func NodeID(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { + logger().Debug("client call", + zap.String("service", "Service"), + zap.String("method", "ID"), + zap.String("input", string(jsonInput)), + ) + + var typedInput node.Void + if err := json.Unmarshal(jsonInput, &typedInput); err != nil { + return nil, err + } + return client.Node().ID(ctx, &typedInput) +} + func NodeEventStream(client *client.Client, ctx context.Context, jsonInput []byte) (GenericServerStreamClient, error) { logger().Debug("client call", zap.String("service", "Service"), @@ -381,36 +398,46 @@ func NodeRunIntegrationTests(client *client.Client, ctx context.Context, jsonInp return client.Node().RunIntegrationTests(ctx, &typedInput) } -func NodeMonitorPeers(client *client.Client, ctx context.Context, jsonInput []byte) (GenericServerStreamClient, error) { +func NodeDebugPing(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { logger().Debug("client call", zap.String("service", "Service"), - zap.String("method", "MonitorPeers"), + zap.String("method", "DebugPing"), zap.String("input", string(jsonInput)), ) - var typedInput node.Void + var typedInput node.PingDestination if err := json.Unmarshal(jsonInput, &typedInput); err != nil { return nil, err } - stream, err := client.Node().MonitorPeers(ctx, &typedInput) - if err != nil { + return client.Node().DebugPing(ctx, &typedInput) +} + +func NodeDeviceInfos(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { + logger().Debug("client call", + zap.String("service", "Service"), + zap.String("method", "DeviceInfos"), + zap.String("input", string(jsonInput)), + ) + + var typedInput node.Void + if err := json.Unmarshal(jsonInput, &typedInput); err != nil { return nil, err } + return client.Node().DeviceInfos(ctx, &typedInput) +} - // start a stream proxy - streamProxy := newGenericServerStreamProxy() - go func() { - for { - data, err := stream.Recv() - streamProxy.queue <- genericStreamEntry{data: data, err: err} - if err != nil { - break - } - } - // FIXME: wait for queue to be empty, then close chan - }() +func NodeAppVersion(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { + logger().Debug("client call", + zap.String("service", "Service"), + zap.String("method", "AppVersion"), + zap.String("input", string(jsonInput)), + ) - return streamProxy, nil + var typedInput node.Void + if err := json.Unmarshal(jsonInput, &typedInput); err != nil { + return nil, err + } + return client.Node().AppVersion(ctx, &typedInput) } func NodePeers(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { @@ -427,38 +454,56 @@ func NodePeers(client *client.Client, ctx context.Context, jsonInput []byte) (in return client.Node().Peers(ctx, &typedInput) } -func NodeDebugPing(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { +func NodeProtocols(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { logger().Debug("client call", zap.String("service", "Service"), - zap.String("method", "DebugPing"), + zap.String("method", "Protocols"), zap.String("input", string(jsonInput)), ) - var typedInput node.PingDestination + var typedInput p2p.Peer if err := json.Unmarshal(jsonInput, &typedInput); err != nil { return nil, err } - return client.Node().DebugPing(ctx, &typedInput) + return client.Node().Protocols(ctx, &typedInput) } -func NodeDeviceInfos(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { +func NodeMonitorBandwidth(client *client.Client, ctx context.Context, jsonInput []byte) (GenericServerStreamClient, error) { logger().Debug("client call", zap.String("service", "Service"), - zap.String("method", "DeviceInfos"), + zap.String("method", "MonitorBandwidth"), zap.String("input", string(jsonInput)), ) - var typedInput node.Void + var typedInput p2p.BandwidthStats if err := json.Unmarshal(jsonInput, &typedInput); err != nil { return nil, err } - return client.Node().DeviceInfos(ctx, &typedInput) + stream, err := client.Node().MonitorBandwidth(ctx, &typedInput) + if err != nil { + return nil, err + } + + // start a stream proxy + streamProxy := newGenericServerStreamProxy() + go func() { + for { + data, err := stream.Recv() + streamProxy.queue <- genericStreamEntry{data: data, err: err} + if err != nil { + break + } + } + // FIXME: wait for queue to be empty, then close chan + }() + + return streamProxy, nil } -func NodeAppVersion(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { +func NodeMonitorPeers(client *client.Client, ctx context.Context, jsonInput []byte) (GenericServerStreamClient, error) { logger().Debug("client call", zap.String("service", "Service"), - zap.String("method", "AppVersion"), + zap.String("method", "MonitorPeers"), zap.String("input", string(jsonInput)), ) @@ -466,7 +511,25 @@ func NodeAppVersion(client *client.Client, ctx context.Context, jsonInput []byte if err := json.Unmarshal(jsonInput, &typedInput); err != nil { return nil, err } - return client.Node().AppVersion(ctx, &typedInput) + stream, err := client.Node().MonitorPeers(ctx, &typedInput) + if err != nil { + return nil, err + } + + // start a stream proxy + streamProxy := newGenericServerStreamProxy() + go func() { + for { + data, err := stream.Recv() + streamProxy.queue <- genericStreamEntry{data: data, err: err} + if err != nil { + break + } + } + // FIXME: wait for queue to be empty, then close chan + }() + + return streamProxy, nil } func NodePanic(client *client.Client, ctx context.Context, jsonInput []byte) (interface{}, error) { diff --git a/core/api/node/graphql/gqlgen.gen.yml b/core/api/node/graphql/gqlgen.gen.yml index 32cd4e8d09..0ff78616be 100644 --- a/core/api/node/graphql/gqlgen.gen.yml +++ b/core/api/node/graphql/gqlgen.gen.yml @@ -1137,6 +1137,35 @@ models: resolver: true + BertyP2pBandwidthStats: + model: berty.tech/core/api/p2p.BandwidthStats + fields: + id: + totalIn: + totalOut: + rateIn: + rateOut: + type: + BertyP2pBandwidthStatsInput: + model: berty.tech/core/api/p2p.BandwidthStats + fields: + id: + totalIn: + totalOut: + rateIn: + rateOut: + type: + BertyP2pBandwidthStatsPayload: + model: berty.tech/core/api/p2p.BandwidthStats + fields: + id: + totalIn: + totalOut: + rateIn: + rateOut: + type: + + BertyP2pPeer: model: berty.tech/core/api/p2p.Peer fields: @@ -1183,6 +1212,19 @@ models: fields: infos: + BertyNodeProtocolsOutput: + model: berty.tech/core/api/node.ProtocolsOutput + fields: + protocols: + BertyNodeProtocolsOutputInput: + model: berty.tech/core/api/node.ProtocolsOutput + fields: + protocols: + BertyNodeProtocolsPayload: + model: berty.tech/core/api/node.ProtocolsOutput + fields: + protocols: + BertyNodeDeviceInfo: model: berty.tech/core/api/node.DeviceInfo fields: diff --git a/core/api/node/graphql/graph/generated/generated.go b/core/api/node/graphql/graph/generated/generated.go index 417a41aa06..caceacf0d4 100644 --- a/core/api/node/graphql/graph/generated/generated.go +++ b/core/api/node/graphql/graph/generated/generated.go @@ -229,6 +229,10 @@ type ComplexityRoot struct { Destination func(childComplexity int) int } + BertyNodeProtocolsPayload struct { + Protocols func(childComplexity int) int + } + BertyNodeVoid struct { T func(childComplexity int) int } @@ -242,6 +246,24 @@ type ComplexityRoot struct { ErrMsg func(childComplexity int) int } + BertyP2pBandwidthStats struct { + Id func(childComplexity int) int + TotalIn func(childComplexity int) int + TotalOut func(childComplexity int) int + RateIn func(childComplexity int) int + RateOut func(childComplexity int) int + Type func(childComplexity int) int + } + + BertyP2pBandwidthStatsPayload struct { + Id func(childComplexity int) int + TotalIn func(childComplexity int) int + TotalOut func(childComplexity int) int + RateIn func(childComplexity int) int + RateOut func(childComplexity int) int + Type func(childComplexity int) int + } + BertyP2pContactRequestAcceptedAttrs struct { T func(childComplexity int) int } @@ -560,6 +582,7 @@ type ComplexityRoot struct { Query struct { Node func(childComplexity int, id string) int + Id func(childComplexity int, T bool) int EventList func(childComplexity int, filter *p2p.Event, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) int GetEvent func(childComplexity int, id string, senderId string, createdAt *time.Time, updatedAt *time.Time, deletedAt *time.Time, sentAt *time.Time, receivedAt *time.Time, ackedAt *time.Time, direction *int32, senderApiVersion uint32, receiverApiVersion uint32, receiverId string, kind *int32, attributes []byte, conversationId string) int ContactList func(childComplexity int, filter *entity.Contact, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) int @@ -567,15 +590,17 @@ type ComplexityRoot struct { ConversationList func(childComplexity int, filter *entity.Conversation, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) int GetConversation func(childComplexity int, id string, createdAt *time.Time, updatedAt *time.Time, deletedAt *time.Time, title string, topic string, members []*entity.ConversationMember) int GetConversationMember func(childComplexity int, id string, createdAt *time.Time, updatedAt *time.Time, deletedAt *time.Time, status *int32, contact *entity.Contact, conversationId string, contactId string) int - Peers func(childComplexity int, T bool) int DeviceInfos func(childComplexity int, T bool) int AppVersion func(childComplexity int, T bool) int + Peers func(childComplexity int, T bool) int + Protocols func(childComplexity int, id string, addrs []string, connection *int32) int Panic func(childComplexity int, T bool) int } Subscription struct { - EventStream func(childComplexity int, filter *p2p.Event) int - MonitorPeers func(childComplexity int, T bool) int + EventStream func(childComplexity int, filter *p2p.Event) int + MonitorBandwidth func(childComplexity int, id *string, totalIn *int64, totalOut *int64, rateIn *float64, rateOut *float64, typeArg *int32) int + MonitorPeers func(childComplexity int, T bool) int } } @@ -644,6 +669,7 @@ type MutationResolver interface { } type QueryResolver interface { Node(ctx context.Context, id string) (models.Node, error) + ID(ctx context.Context, T bool) (*p2p.Peer, error) EventList(ctx context.Context, filter *p2p.Event, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) (*node.EventListConnection, error) GetEvent(ctx context.Context, id string, senderId string, createdAt *time.Time, updatedAt *time.Time, deletedAt *time.Time, sentAt *time.Time, receivedAt *time.Time, ackedAt *time.Time, direction *int32, senderApiVersion uint32, receiverApiVersion uint32, receiverId string, kind *int32, attributes []byte, conversationId string) (*p2p.Event, error) ContactList(ctx context.Context, filter *entity.Contact, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) (*node.ContactListConnection, error) @@ -651,13 +677,15 @@ type QueryResolver interface { ConversationList(ctx context.Context, filter *entity.Conversation, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) (*node.ConversationListConnection, error) GetConversation(ctx context.Context, id string, createdAt *time.Time, updatedAt *time.Time, deletedAt *time.Time, title string, topic string, members []*entity.ConversationMember) (*entity.Conversation, error) GetConversationMember(ctx context.Context, id string, createdAt *time.Time, updatedAt *time.Time, deletedAt *time.Time, status *int32, contact *entity.Contact, conversationId string, contactId string) (*entity.ConversationMember, error) - Peers(ctx context.Context, T bool) (*p2p.Peers, error) DeviceInfos(ctx context.Context, T bool) (*node.DeviceInfosOutput, error) AppVersion(ctx context.Context, T bool) (*node.AppVersionOutput, error) + Peers(ctx context.Context, T bool) (*p2p.Peers, error) + Protocols(ctx context.Context, id string, addrs []string, connection *int32) (*node.ProtocolsOutput, error) Panic(ctx context.Context, T bool) (*node.Void, error) } type SubscriptionResolver interface { EventStream(ctx context.Context, filter *p2p.Event) (<-chan *p2p.Event, error) + MonitorBandwidth(ctx context.Context, id *string, totalIn *int64, totalOut *int64, rateIn *float64, rateOut *float64, typeArg *int32) (<-chan *p2p.BandwidthStats, error) MonitorPeers(ctx context.Context, T bool) (<-chan *p2p.Peer, error) } @@ -1358,6 +1386,21 @@ func field_Query_node_args(rawArgs map[string]interface{}) (map[string]interface } +func field_Query_ID_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["T"]; ok { + var err error + arg0, err = models.UnmarshalBool(tmp) + if err != nil { + return nil, err + } + } + args["T"] = arg0 + return args, nil + +} + func field_Query_EventList_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 *p2p.Event @@ -2185,7 +2228,7 @@ func field_Query_GetConversationMember_args(rawArgs map[string]interface{}) (map } -func field_Query_Peers_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func field_Query_DeviceInfos_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["T"]; ok { @@ -2200,7 +2243,7 @@ func field_Query_Peers_args(rawArgs map[string]interface{}) (map[string]interfac } -func field_Query_DeviceInfos_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func field_Query_AppVersion_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["T"]; ok { @@ -2215,7 +2258,7 @@ func field_Query_DeviceInfos_args(rawArgs map[string]interface{}) (map[string]in } -func field_Query_AppVersion_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { +func field_Query_Peers_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 bool if tmp, ok := rawArgs["T"]; ok { @@ -2230,6 +2273,55 @@ func field_Query_AppVersion_args(rawArgs map[string]interface{}) (map[string]int } +func field_Query_Protocols_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + var err error + arg0, err = models.UnmarshalString(tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + var arg1 []string + if tmp, ok := rawArgs["addrs"]; ok { + var err error + var rawIf1 []interface{} + if tmp != nil { + if tmp1, ok := tmp.([]interface{}); ok { + rawIf1 = tmp1 + } else { + rawIf1 = []interface{}{tmp} + } + } + arg1 = make([]string, len(rawIf1)) + for idx1 := range rawIf1 { + arg1[idx1], err = models.UnmarshalString(rawIf1[idx1]) + } + if err != nil { + return nil, err + } + } + args["addrs"] = arg1 + var arg2 *int32 + if tmp, ok := rawArgs["connection"]; ok { + var err error + var ptr1 int32 + if tmp != nil { + ptr1, err = models.UnmarshalEnum(tmp) + arg2 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["connection"] = arg2 + return args, nil + +} + func field_Query_Panic_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 bool @@ -2280,6 +2372,96 @@ func field_Subscription_EventStream_args(rawArgs map[string]interface{}) (map[st } +func field_Subscription_MonitorBandwidth_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { + args := map[string]interface{}{} + var arg0 *string + if tmp, ok := rawArgs["id"]; ok { + var err error + var ptr1 string + if tmp != nil { + ptr1, err = models.UnmarshalString(tmp) + arg0 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["id"] = arg0 + var arg1 *int64 + if tmp, ok := rawArgs["totalIn"]; ok { + var err error + var ptr1 int64 + if tmp != nil { + ptr1, err = models.UnmarshalInt64(tmp) + arg1 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["totalIn"] = arg1 + var arg2 *int64 + if tmp, ok := rawArgs["totalOut"]; ok { + var err error + var ptr1 int64 + if tmp != nil { + ptr1, err = models.UnmarshalInt64(tmp) + arg2 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["totalOut"] = arg2 + var arg3 *float64 + if tmp, ok := rawArgs["rateIn"]; ok { + var err error + var ptr1 float64 + if tmp != nil { + ptr1, err = models.UnmarshalDouble(tmp) + arg3 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["rateIn"] = arg3 + var arg4 *float64 + if tmp, ok := rawArgs["rateOut"]; ok { + var err error + var ptr1 float64 + if tmp != nil { + ptr1, err = models.UnmarshalDouble(tmp) + arg4 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["rateOut"] = arg4 + var arg5 *int32 + if tmp, ok := rawArgs["type"]; ok { + var err error + var ptr1 int32 + if tmp != nil { + ptr1, err = models.UnmarshalEnum(tmp) + arg5 = &ptr1 + } + + if err != nil { + return nil, err + } + } + args["type"] = arg5 + return args, nil + +} + func field_Subscription_MonitorPeers_args(rawArgs map[string]interface{}) (map[string]interface{}, error) { args := map[string]interface{}{} var arg0 bool @@ -3066,6 +3248,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.BertyNodePingDestination.Destination(childComplexity), true + case "BertyNodeProtocolsPayload.protocols": + if e.complexity.BertyNodeProtocolsPayload.Protocols == nil { + break + } + + return e.complexity.BertyNodeProtocolsPayload.Protocols(childComplexity), true + case "BertyNodeVoid.T": if e.complexity.BertyNodeVoid.T == nil { break @@ -3094,6 +3283,90 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.BertyP2pAckAttrs.ErrMsg(childComplexity), true + case "BertyP2pBandwidthStats.id": + if e.complexity.BertyP2pBandwidthStats.Id == nil { + break + } + + return e.complexity.BertyP2pBandwidthStats.Id(childComplexity), true + + case "BertyP2pBandwidthStats.totalIn": + if e.complexity.BertyP2pBandwidthStats.TotalIn == nil { + break + } + + return e.complexity.BertyP2pBandwidthStats.TotalIn(childComplexity), true + + case "BertyP2pBandwidthStats.totalOut": + if e.complexity.BertyP2pBandwidthStats.TotalOut == nil { + break + } + + return e.complexity.BertyP2pBandwidthStats.TotalOut(childComplexity), true + + case "BertyP2pBandwidthStats.rateIn": + if e.complexity.BertyP2pBandwidthStats.RateIn == nil { + break + } + + return e.complexity.BertyP2pBandwidthStats.RateIn(childComplexity), true + + case "BertyP2pBandwidthStats.rateOut": + if e.complexity.BertyP2pBandwidthStats.RateOut == nil { + break + } + + return e.complexity.BertyP2pBandwidthStats.RateOut(childComplexity), true + + case "BertyP2pBandwidthStats.type": + if e.complexity.BertyP2pBandwidthStats.Type == nil { + break + } + + return e.complexity.BertyP2pBandwidthStats.Type(childComplexity), true + + case "BertyP2pBandwidthStatsPayload.id": + if e.complexity.BertyP2pBandwidthStatsPayload.Id == nil { + break + } + + return e.complexity.BertyP2pBandwidthStatsPayload.Id(childComplexity), true + + case "BertyP2pBandwidthStatsPayload.totalIn": + if e.complexity.BertyP2pBandwidthStatsPayload.TotalIn == nil { + break + } + + return e.complexity.BertyP2pBandwidthStatsPayload.TotalIn(childComplexity), true + + case "BertyP2pBandwidthStatsPayload.totalOut": + if e.complexity.BertyP2pBandwidthStatsPayload.TotalOut == nil { + break + } + + return e.complexity.BertyP2pBandwidthStatsPayload.TotalOut(childComplexity), true + + case "BertyP2pBandwidthStatsPayload.rateIn": + if e.complexity.BertyP2pBandwidthStatsPayload.RateIn == nil { + break + } + + return e.complexity.BertyP2pBandwidthStatsPayload.RateIn(childComplexity), true + + case "BertyP2pBandwidthStatsPayload.rateOut": + if e.complexity.BertyP2pBandwidthStatsPayload.RateOut == nil { + break + } + + return e.complexity.BertyP2pBandwidthStatsPayload.RateOut(childComplexity), true + + case "BertyP2pBandwidthStatsPayload.type": + if e.complexity.BertyP2pBandwidthStatsPayload.Type == nil { + break + } + + return e.complexity.BertyP2pBandwidthStatsPayload.Type(childComplexity), true + case "BertyP2pContactRequestAcceptedAttrs.T": if e.complexity.BertyP2pContactRequestAcceptedAttrs.T == nil { break @@ -4444,6 +4717,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Node(childComplexity, args["id"].(string)), true + case "Query.ID": + if e.complexity.Query.Id == nil { + break + } + + args, err := field_Query_ID_args(rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Id(childComplexity, args["T"].(bool)), true + case "Query.EventList": if e.complexity.Query.EventList == nil { break @@ -4528,18 +4813,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.GetConversationMember(childComplexity, args["id"].(string), args["createdAt"].(*time.Time), args["updatedAt"].(*time.Time), args["deletedAt"].(*time.Time), args["status"].(*int32), args["contact"].(*entity.Contact), args["conversationId"].(string), args["contactId"].(string)), true - case "Query.Peers": - if e.complexity.Query.Peers == nil { - break - } - - args, err := field_Query_Peers_args(rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Peers(childComplexity, args["T"].(bool)), true - case "Query.DeviceInfos": if e.complexity.Query.DeviceInfos == nil { break @@ -4564,6 +4837,30 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.AppVersion(childComplexity, args["T"].(bool)), true + case "Query.Peers": + if e.complexity.Query.Peers == nil { + break + } + + args, err := field_Query_Peers_args(rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Peers(childComplexity, args["T"].(bool)), true + + case "Query.Protocols": + if e.complexity.Query.Protocols == nil { + break + } + + args, err := field_Query_Protocols_args(rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Protocols(childComplexity, args["id"].(string), args["addrs"].([]string), args["connection"].(*int32)), true + case "Query.Panic": if e.complexity.Query.Panic == nil { break @@ -4588,6 +4885,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Subscription.EventStream(childComplexity, args["filter"].(*p2p.Event)), true + case "Subscription.MonitorBandwidth": + if e.complexity.Subscription.MonitorBandwidth == nil { + break + } + + args, err := field_Subscription_MonitorBandwidth_args(rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Subscription.MonitorBandwidth(childComplexity, args["id"].(*string), args["totalIn"].(*int64), args["totalOut"].(*int64), args["rateIn"].(*float64), args["rateOut"].(*float64), args["type"].(*int32)), true + case "Subscription.MonitorPeers": if e.complexity.Subscription.MonitorPeers == nil { break @@ -8261,11 +8570,11 @@ func (ec *executionContext) _BertyNodePingDestination_destination(ctx context.Co return models.MarshalString(res) } -var bertyNodeVoidImplementors = []string{"BertyNodeVoid"} +var bertyNodeProtocolsPayloadImplementors = []string{"BertyNodeProtocolsPayload"} // nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _BertyNodeVoid(ctx context.Context, sel ast.SelectionSet, obj *node.Void) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, bertyNodeVoidImplementors) +func (ec *executionContext) _BertyNodeProtocolsPayload(ctx context.Context, sel ast.SelectionSet, obj *node.ProtocolsOutput) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, bertyNodeProtocolsPayloadImplementors) out := graphql.NewOrderedMap(len(fields)) invalid := false @@ -8274,12 +8583,9 @@ func (ec *executionContext) _BertyNodeVoid(ctx context.Context, sel ast.Selectio switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("BertyNodeVoid") - case "T": - out.Values[i] = ec._BertyNodeVoid_T(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } + out.Values[i] = graphql.MarshalString("BertyNodeProtocolsPayload") + case "protocols": + out.Values[i] = ec._BertyNodeProtocolsPayload_protocols(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -8292,29 +8598,88 @@ func (ec *executionContext) _BertyNodeVoid(ctx context.Context, sel ast.Selectio } // nolint: vetshadow -func (ec *executionContext) _BertyNodeVoid_T(ctx context.Context, field graphql.CollectedField, obj *node.Void) graphql.Marshaler { +func (ec *executionContext) _BertyNodeProtocolsPayload_protocols(ctx context.Context, field graphql.CollectedField, obj *node.ProtocolsOutput) graphql.Marshaler { rctx := &graphql.ResolverContext{ - Object: "BertyNodeVoid", + Object: "BertyNodeProtocolsPayload", Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.T, nil + return obj.Protocols, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.([]string) rctx.Result = res - return models.MarshalBool(res) -} -var bertyNodeVoidPayloadImplementors = []string{"BertyNodeVoidPayload"} + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return models.MarshalString(res[idx1]) + }() + } + + return arr1 +} + +var bertyNodeVoidImplementors = []string{"BertyNodeVoid"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _BertyNodeVoid(ctx context.Context, sel ast.SelectionSet, obj *node.Void) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, bertyNodeVoidImplementors) + + out := graphql.NewOrderedMap(len(fields)) + invalid := false + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BertyNodeVoid") + case "T": + out.Values[i] = ec._BertyNodeVoid_T(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + if invalid { + return graphql.Null + } + return out +} + +// nolint: vetshadow +func (ec *executionContext) _BertyNodeVoid_T(ctx context.Context, field graphql.CollectedField, obj *node.Void) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyNodeVoid", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.T, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + return models.MarshalBool(res) +} + +var bertyNodeVoidPayloadImplementors = []string{"BertyNodeVoidPayload"} // nolint: gocyclo, errcheck, gas, goconst func (ec *executionContext) _BertyNodeVoidPayload(ctx context.Context, sel ast.SelectionSet, obj *node.Void) graphql.Marshaler { @@ -8341,114 +8706,428 @@ func (ec *executionContext) _BertyNodeVoidPayload(ctx context.Context, sel ast.S if invalid { return graphql.Null } - return out + return out +} + +// nolint: vetshadow +func (ec *executionContext) _BertyNodeVoidPayload_T(ctx context.Context, field graphql.CollectedField, obj *node.Void) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyNodeVoidPayload", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.T, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + rctx.Result = res + return models.MarshalBool(res) +} + +var bertyP2pAckAttrsImplementors = []string{"BertyP2pAckAttrs"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _BertyP2pAckAttrs(ctx context.Context, sel ast.SelectionSet, obj *p2p.AckAttrs) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, bertyP2pAckAttrsImplementors) + + out := graphql.NewOrderedMap(len(fields)) + invalid := false + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BertyP2pAckAttrs") + case "ids": + out.Values[i] = ec._BertyP2pAckAttrs_ids(ctx, field, obj) + case "ErrMsg": + out.Values[i] = ec._BertyP2pAckAttrs_ErrMsg(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalid = true + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + if invalid { + return graphql.Null + } + return out +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pAckAttrs_ids(ctx context.Context, field graphql.CollectedField, obj *p2p.AckAttrs) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pAckAttrs", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IDs, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]string) + rctx.Result = res + + arr1 := make(graphql.Array, len(res)) + + for idx1 := range res { + arr1[idx1] = func() graphql.Marshaler { + return models.MarshalString(res[idx1]) + }() + } + + return arr1 +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pAckAttrs_ErrMsg(ctx context.Context, field graphql.CollectedField, obj *p2p.AckAttrs) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pAckAttrs", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ErrMsg, nil + }) + if resTmp == nil { + if !ec.HasError(rctx) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + return models.MarshalString(res) +} + +var bertyP2pBandwidthStatsImplementors = []string{"BertyP2pBandwidthStats"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _BertyP2pBandwidthStats(ctx context.Context, sel ast.SelectionSet, obj *p2p.BandwidthStats) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, bertyP2pBandwidthStatsImplementors) + + out := graphql.NewOrderedMap(len(fields)) + invalid := false + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BertyP2pBandwidthStats") + case "id": + out.Values[i] = ec._BertyP2pBandwidthStats_id(ctx, field, obj) + case "totalIn": + out.Values[i] = ec._BertyP2pBandwidthStats_totalIn(ctx, field, obj) + case "totalOut": + out.Values[i] = ec._BertyP2pBandwidthStats_totalOut(ctx, field, obj) + case "rateIn": + out.Values[i] = ec._BertyP2pBandwidthStats_rateIn(ctx, field, obj) + case "rateOut": + out.Values[i] = ec._BertyP2pBandwidthStats_rateOut(ctx, field, obj) + case "type": + out.Values[i] = ec._BertyP2pBandwidthStats_type(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + if invalid { + return graphql.Null + } + return out +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStats_id(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStats", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + return models.MarshalString(res) +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStats_totalIn(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStats", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalIn, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(int64) + rctx.Result = res + return models.MarshalInt64(res) +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStats_totalOut(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStats", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalOut, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(int64) + rctx.Result = res + return models.MarshalInt64(res) +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStats_rateIn(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStats", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RateIn, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + return models.MarshalDouble(res) +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStats_rateOut(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStats", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RateOut, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + return models.MarshalDouble(res) +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStats_type(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStats", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(p2p.MetricsType) + rctx.Result = res + return models.MarshalEnum(int32(res)) +} + +var bertyP2pBandwidthStatsPayloadImplementors = []string{"BertyP2pBandwidthStatsPayload"} + +// nolint: gocyclo, errcheck, gas, goconst +func (ec *executionContext) _BertyP2pBandwidthStatsPayload(ctx context.Context, sel ast.SelectionSet, obj *p2p.BandwidthStats) graphql.Marshaler { + fields := graphql.CollectFields(ctx, sel, bertyP2pBandwidthStatsPayloadImplementors) + + out := graphql.NewOrderedMap(len(fields)) + invalid := false + for i, field := range fields { + out.Keys[i] = field.Alias + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("BertyP2pBandwidthStatsPayload") + case "id": + out.Values[i] = ec._BertyP2pBandwidthStatsPayload_id(ctx, field, obj) + case "totalIn": + out.Values[i] = ec._BertyP2pBandwidthStatsPayload_totalIn(ctx, field, obj) + case "totalOut": + out.Values[i] = ec._BertyP2pBandwidthStatsPayload_totalOut(ctx, field, obj) + case "rateIn": + out.Values[i] = ec._BertyP2pBandwidthStatsPayload_rateIn(ctx, field, obj) + case "rateOut": + out.Values[i] = ec._BertyP2pBandwidthStatsPayload_rateOut(ctx, field, obj) + case "type": + out.Values[i] = ec._BertyP2pBandwidthStatsPayload_type(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + + if invalid { + return graphql.Null + } + return out +} + +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStatsPayload_id(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStatsPayload", + Args: nil, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + rctx.Result = res + return models.MarshalString(res) } // nolint: vetshadow -func (ec *executionContext) _BertyNodeVoidPayload_T(ctx context.Context, field graphql.CollectedField, obj *node.Void) graphql.Marshaler { +func (ec *executionContext) _BertyP2pBandwidthStatsPayload_totalIn(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { rctx := &graphql.ResolverContext{ - Object: "BertyNodeVoidPayload", + Object: "BertyP2pBandwidthStatsPayload", Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.T, nil + return obj.TotalIn, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(bool) + res := resTmp.(int64) rctx.Result = res - return models.MarshalBool(res) + return models.MarshalInt64(res) } -var bertyP2pAckAttrsImplementors = []string{"BertyP2pAckAttrs"} - -// nolint: gocyclo, errcheck, gas, goconst -func (ec *executionContext) _BertyP2pAckAttrs(ctx context.Context, sel ast.SelectionSet, obj *p2p.AckAttrs) graphql.Marshaler { - fields := graphql.CollectFields(ctx, sel, bertyP2pAckAttrsImplementors) - - out := graphql.NewOrderedMap(len(fields)) - invalid := false - for i, field := range fields { - out.Keys[i] = field.Alias - - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("BertyP2pAckAttrs") - case "ids": - out.Values[i] = ec._BertyP2pAckAttrs_ids(ctx, field, obj) - case "ErrMsg": - out.Values[i] = ec._BertyP2pAckAttrs_ErrMsg(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalid = true - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStatsPayload_totalOut(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStatsPayload", + Args: nil, + Field: field, } - - if invalid { + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalOut, nil + }) + if resTmp == nil { return graphql.Null } - return out + res := resTmp.(int64) + rctx.Result = res + return models.MarshalInt64(res) } // nolint: vetshadow -func (ec *executionContext) _BertyP2pAckAttrs_ids(ctx context.Context, field graphql.CollectedField, obj *p2p.AckAttrs) graphql.Marshaler { +func (ec *executionContext) _BertyP2pBandwidthStatsPayload_rateIn(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { rctx := &graphql.ResolverContext{ - Object: "BertyP2pAckAttrs", + Object: "BertyP2pBandwidthStatsPayload", Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.IDs, nil + return obj.RateIn, nil }) if resTmp == nil { return graphql.Null } - res := resTmp.([]string) + res := resTmp.(float64) rctx.Result = res + return models.MarshalDouble(res) +} - arr1 := make(graphql.Array, len(res)) - - for idx1 := range res { - arr1[idx1] = func() graphql.Marshaler { - return models.MarshalString(res[idx1]) - }() +// nolint: vetshadow +func (ec *executionContext) _BertyP2pBandwidthStatsPayload_rateOut(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { + rctx := &graphql.ResolverContext{ + Object: "BertyP2pBandwidthStatsPayload", + Args: nil, + Field: field, } - - return arr1 + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RateOut, nil + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(float64) + rctx.Result = res + return models.MarshalDouble(res) } // nolint: vetshadow -func (ec *executionContext) _BertyP2pAckAttrs_ErrMsg(ctx context.Context, field graphql.CollectedField, obj *p2p.AckAttrs) graphql.Marshaler { +func (ec *executionContext) _BertyP2pBandwidthStatsPayload_type(ctx context.Context, field graphql.CollectedField, obj *p2p.BandwidthStats) graphql.Marshaler { rctx := &graphql.ResolverContext{ - Object: "BertyP2pAckAttrs", + Object: "BertyP2pBandwidthStatsPayload", Args: nil, Field: field, } ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ErrMsg, nil + return obj.Type, nil }) if resTmp == nil { - if !ec.HasError(rctx) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(p2p.MetricsType) rctx.Result = res - return models.MarshalString(res) + return models.MarshalEnum(int32(res)) } var bertyP2pContactRequestAcceptedAttrsImplementors = []string{"BertyP2pContactRequestAcceptedAttrs"} @@ -16199,6 +16878,12 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Values[i] = ec._Query_node(ctx, field) wg.Done() }(i, field) + case "ID": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_ID(ctx, field) + wg.Done() + }(i, field) case "EventList": wg.Add(1) go func(i int, field graphql.CollectedField) { @@ -16241,12 +16926,6 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Values[i] = ec._Query_GetConversationMember(ctx, field) wg.Done() }(i, field) - case "Peers": - wg.Add(1) - go func(i int, field graphql.CollectedField) { - out.Values[i] = ec._Query_Peers(ctx, field) - wg.Done() - }(i, field) case "DeviceInfos": wg.Add(1) go func(i int, field graphql.CollectedField) { @@ -16259,6 +16938,18 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr out.Values[i] = ec._Query_AppVersion(ctx, field) wg.Done() }(i, field) + case "Peers": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_Peers(ctx, field) + wg.Done() + }(i, field) + case "Protocols": + wg.Add(1) + go func(i int, field graphql.CollectedField) { + out.Values[i] = ec._Query_Protocols(ctx, field) + wg.Done() + }(i, field) case "Panic": wg.Add(1) go func(i int, field graphql.CollectedField) { @@ -16307,6 +16998,37 @@ func (ec *executionContext) _Query_node(ctx context.Context, field graphql.Colle return ec._Node(ctx, field.Selections, &res) } +// nolint: vetshadow +func (ec *executionContext) _Query_ID(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args, err := field_Query_ID_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().ID(rctx, args["T"].(bool)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*p2p.Peer) + rctx.Result = res + + if res == nil { + return graphql.Null + } + + return ec._BertyP2pPeerPayload(ctx, field.Selections, res) +} + // nolint: vetshadow func (ec *executionContext) _Query_EventList(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) @@ -16525,9 +17247,9 @@ func (ec *executionContext) _Query_GetConversationMember(ctx context.Context, fi } // nolint: vetshadow -func (ec *executionContext) _Query_Peers(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Query_DeviceInfos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_Peers_args(rawArgs) + args, err := field_Query_DeviceInfos_args(rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -16540,25 +17262,25 @@ func (ec *executionContext) _Query_Peers(ctx context.Context, field graphql.Coll ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Peers(rctx, args["T"].(bool)) + return ec.resolvers.Query().DeviceInfos(rctx, args["T"].(bool)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*p2p.Peers) + res := resTmp.(*node.DeviceInfosOutput) rctx.Result = res if res == nil { return graphql.Null } - return ec._BertyP2pPeersPayload(ctx, field.Selections, res) + return ec._BertyNodeDeviceInfosPayload(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Query_DeviceInfos(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Query_AppVersion(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_DeviceInfos_args(rawArgs) + args, err := field_Query_AppVersion_args(rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -16571,25 +17293,25 @@ func (ec *executionContext) _Query_DeviceInfos(ctx context.Context, field graphq ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().DeviceInfos(rctx, args["T"].(bool)) + return ec.resolvers.Query().AppVersion(rctx, args["T"].(bool)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*node.DeviceInfosOutput) + res := resTmp.(*node.AppVersionOutput) rctx.Result = res if res == nil { return graphql.Null } - return ec._BertyNodeDeviceInfosPayload(ctx, field.Selections, res) + return ec._BertyNodeAppVersionPayload(ctx, field.Selections, res) } // nolint: vetshadow -func (ec *executionContext) _Query_AppVersion(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { +func (ec *executionContext) _Query_Peers(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) - args, err := field_Query_AppVersion_args(rawArgs) + args, err := field_Query_Peers_args(rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -16602,19 +17324,50 @@ func (ec *executionContext) _Query_AppVersion(ctx context.Context, field graphql ctx = graphql.WithResolverContext(ctx, rctx) resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().AppVersion(rctx, args["T"].(bool)) + return ec.resolvers.Query().Peers(rctx, args["T"].(bool)) }) if resTmp == nil { return graphql.Null } - res := resTmp.(*node.AppVersionOutput) + res := resTmp.(*p2p.Peers) rctx.Result = res if res == nil { return graphql.Null } - return ec._BertyNodeAppVersionPayload(ctx, field.Selections, res) + return ec._BertyP2pPeersPayload(ctx, field.Selections, res) +} + +// nolint: vetshadow +func (ec *executionContext) _Query_Protocols(ctx context.Context, field graphql.CollectedField) graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args, err := field_Query_Protocols_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + rctx := &graphql.ResolverContext{ + Object: "Query", + Args: args, + Field: field, + } + ctx = graphql.WithResolverContext(ctx, rctx) + resTmp := ec.FieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().Protocols(rctx, args["id"].(string), args["addrs"].([]string), args["connection"].(*int32)) + }) + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*node.ProtocolsOutput) + rctx.Result = res + + if res == nil { + return graphql.Null + } + + return ec._BertyNodeProtocolsPayload(ctx, field.Selections, res) } // nolint: vetshadow @@ -16720,6 +17473,8 @@ func (ec *executionContext) _Subscription(ctx context.Context, sel ast.Selection switch fields[0].Name { case "EventStream": return ec._Subscription_EventStream(ctx, fields[0]) + case "MonitorBandwidth": + return ec._Subscription_MonitorBandwidth(ctx, fields[0]) case "MonitorPeers": return ec._Subscription_MonitorPeers(ctx, fields[0]) default: @@ -16760,6 +17515,39 @@ func (ec *executionContext) _Subscription_EventStream(ctx context.Context, field } } +func (ec *executionContext) _Subscription_MonitorBandwidth(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { + rawArgs := field.ArgumentMap(ec.Variables) + args, err := field_Subscription_MonitorBandwidth_args(rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Field: field, + }) + rctx := ctx // FIXME: subscriptions are missing request middleware stack https://github.com/99designs/gqlgen/issues/259 + results, err := ec.resolvers.Subscription().MonitorBandwidth(rctx, args["id"].(*string), args["totalIn"].(*int64), args["totalOut"].(*int64), args["rateIn"].(*float64), args["rateOut"].(*float64), args["type"].(*int32)) + if err != nil { + ec.Error(ctx, err) + return nil + } + return func() graphql.Marshaler { + res, ok := <-results + if !ok { + return nil + } + var out graphql.OrderedMap + out.Add(field.Alias, func() graphql.Marshaler { + if res == nil { + return graphql.Null + } + + return ec._BertyP2pBandwidthStatsPayload(ctx, field.Selections, res) + }()) + return &out + } +} + func (ec *executionContext) _Subscription_MonitorPeers(ctx context.Context, field graphql.CollectedField) func() graphql.Marshaler { rawArgs := field.ArgumentMap(ec.Variables) args, err := field_Subscription_MonitorPeers_args(rawArgs) @@ -19061,6 +19849,19 @@ type BertyP2pEvent implements Node { +type BertyP2pBandwidthStats { + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum +} + + + + + type BertyP2pPeer { id: String! addrs: [String!] @@ -19122,6 +19923,11 @@ type BertyNodePageInfo { type BertyNodeVoid { T: Bool! } +type BertyP2pPeerPayload { + id: String! + addrs: [String!] + connection: Enum +} input BertyP2pEventInput { id: ID! senderId: String! @@ -19251,23 +20057,32 @@ type BertyNodeIntegrationTestPayload { startedAt: GoogleProtobufTimestamp finishedAt: GoogleProtobufTimestamp } -type BertyP2pPeerPayload { - id: String! - addrs: [String!] - connection: Enum -} -type BertyP2pPeersPayload { - list: [BertyP2pPeer] -} type BertyNodeDeviceInfosPayload { infos: [BertyNodeDeviceInfo] } type BertyNodeAppVersionPayload { version: String! } +type BertyP2pPeersPayload { + list: [BertyP2pPeer] +} +type BertyNodeProtocolsPayload { + protocols: [String!] +} +type BertyP2pBandwidthStatsPayload { + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum +} type Query { node(id: ID!): Node + ID( + T: Bool! + ): BertyP2pPeerPayload EventList( filter: BertyP2pEventInput orderBy: String! @@ -19344,15 +20159,20 @@ type Query { conversationId: String! contactId: String! ): BertyEntityConversationMemberPayload - Peers( - T: Bool! - ): BertyP2pPeersPayload DeviceInfos( T: Bool! ): BertyNodeDeviceInfosPayload AppVersion( T: Bool! ): BertyNodeAppVersionPayload + Peers( + T: Bool! + ): BertyP2pPeersPayload + Protocols( + id: String! + addrs: [String!] + connection: Enum + ): BertyNodeProtocolsPayload Panic( T: Bool! ): BertyNodeVoidPayload @@ -19431,6 +20251,14 @@ type Subscription { EventStream( filter: BertyP2pEventInput ): BertyP2pEventPayload + MonitorBandwidth( + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum + ): BertyP2pBandwidthStatsPayload MonitorPeers( T: Bool! ): BertyP2pPeerPayload diff --git a/core/api/node/graphql/resolver.go b/core/api/node/graphql/resolver.go index 55ea9734e0..9b1d903bea 100644 --- a/core/api/node/graphql/resolver.go +++ b/core/api/node/graphql/resolver.go @@ -252,6 +252,16 @@ func (r *queryResolver) Node(ctx context.Context, id string) (models.Node, error } } +func (r *queryResolver) ID(ctx context.Context, T bool) (*p2p.Peer, error) { + return r.client.ID(ctx, &node.Void{T: T}) +} + +func (r *queryResolver) Protocols(ctx context.Context, id string, _ []string, _ *int32) (*node.ProtocolsOutput, error) { + return r.client.Protocols(ctx, &p2p.Peer{ + ID: id, + }) +} + func (r *queryResolver) EventList(ctx context.Context, filter *p2p.Event, orderBy string, orderDesc bool, first *int32, after *string, last *int32, before *string) (*node.EventListConnection, error) { if filter != nil { if filter.ID != "" { @@ -539,6 +549,45 @@ func (r *subscriptionResolver) MonitorPeers(ctx context.Context, _ bool) (<-chan return channel, nil } +func (r *subscriptionResolver) MonitorBandwidth(ctx context.Context, id *string, _ *int64, _ *int64, _ *float64, _ *float64, mtype *int32) (<-chan *p2p.BandwidthStats, error) { + if mtype == nil { + _mtype := int32(p2p.MetricsType_GLOBAL) + mtype = &_mtype + } + + if id == nil { + var _id string + id = &_id + } + + stream, err := r.client.MonitorBandwidth(ctx, &p2p.BandwidthStats{ + ID: *id, + Type: p2p.MetricsType(*mtype), + }) + + if err != nil { + + return nil, err + } + + channel := make(chan *p2p.BandwidthStats, 10) + go func() { + for { + elem, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + // logger().Error(err.Error()) + break + } + channel <- elem + } + }() + + return channel, nil +} + // Helpers func getPagination(first *int32, after *string, last *int32, before *string) *node.Pagination { pagination := &node.Pagination{} diff --git a/core/api/node/graphql/service.gen.graphql b/core/api/node/graphql/service.gen.graphql index bcd04a2d07..7db01c66c1 100644 --- a/core/api/node/graphql/service.gen.graphql +++ b/core/api/node/graphql/service.gen.graphql @@ -372,6 +372,19 @@ type BertyP2pEvent implements Node { +type BertyP2pBandwidthStats { + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum +} + + + + + type BertyP2pPeer { id: String! addrs: [String!] @@ -433,6 +446,11 @@ type BertyNodePageInfo { type BertyNodeVoid { T: Bool! } +type BertyP2pPeerPayload { + id: String! + addrs: [String!] + connection: Enum +} input BertyP2pEventInput { id: ID! senderId: String! @@ -562,23 +580,32 @@ type BertyNodeIntegrationTestPayload { startedAt: GoogleProtobufTimestamp finishedAt: GoogleProtobufTimestamp } -type BertyP2pPeerPayload { - id: String! - addrs: [String!] - connection: Enum -} -type BertyP2pPeersPayload { - list: [BertyP2pPeer] -} type BertyNodeDeviceInfosPayload { infos: [BertyNodeDeviceInfo] } type BertyNodeAppVersionPayload { version: String! } +type BertyP2pPeersPayload { + list: [BertyP2pPeer] +} +type BertyNodeProtocolsPayload { + protocols: [String!] +} +type BertyP2pBandwidthStatsPayload { + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum +} type Query { node(id: ID!): Node + ID( + T: Bool! + ): BertyP2pPeerPayload EventList( filter: BertyP2pEventInput orderBy: String! @@ -655,15 +682,20 @@ type Query { conversationId: String! contactId: String! ): BertyEntityConversationMemberPayload - Peers( - T: Bool! - ): BertyP2pPeersPayload DeviceInfos( T: Bool! ): BertyNodeDeviceInfosPayload AppVersion( T: Bool! ): BertyNodeAppVersionPayload + Peers( + T: Bool! + ): BertyP2pPeersPayload + Protocols( + id: String! + addrs: [String!] + connection: Enum + ): BertyNodeProtocolsPayload Panic( T: Bool! ): BertyNodeVoidPayload @@ -742,6 +774,14 @@ type Subscription { EventStream( filter: BertyP2pEventInput ): BertyP2pEventPayload + MonitorBandwidth( + id: String + totalIn: Int64 + totalOut: Int64 + rateIn: Double + rateOut: Double + type: Enum + ): BertyP2pBandwidthStatsPayload MonitorPeers( T: Bool! ): BertyP2pPeerPayload diff --git a/core/api/node/service.pb.go b/core/api/node/service.pb.go index 2f2263d8cb..9ef28d5b45 100644 --- a/core/api/node/service.pb.go +++ b/core/api/node/service.pb.go @@ -46,7 +46,7 @@ func (m *DeviceInfosOutput) Reset() { *m = DeviceInfosOutput{} } func (m *DeviceInfosOutput) String() string { return proto.CompactTextString(m) } func (*DeviceInfosOutput) ProtoMessage() {} func (*DeviceInfosOutput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{0} + return fileDescriptor_service_ae8497c40577b9fc, []int{0} } func (m *DeviceInfosOutput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -82,6 +82,53 @@ func (m *DeviceInfosOutput) GetInfos() []*DeviceInfo { return nil } +type ProtocolsOutput struct { + Protocols []string `protobuf:"bytes,1,rep,name=protocols" json:"protocols,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ProtocolsOutput) Reset() { *m = ProtocolsOutput{} } +func (m *ProtocolsOutput) String() string { return proto.CompactTextString(m) } +func (*ProtocolsOutput) ProtoMessage() {} +func (*ProtocolsOutput) Descriptor() ([]byte, []int) { + return fileDescriptor_service_ae8497c40577b9fc, []int{1} +} +func (m *ProtocolsOutput) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProtocolsOutput) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProtocolsOutput.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (dst *ProtocolsOutput) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProtocolsOutput.Merge(dst, src) +} +func (m *ProtocolsOutput) XXX_Size() int { + return m.Size() +} +func (m *ProtocolsOutput) XXX_DiscardUnknown() { + xxx_messageInfo_ProtocolsOutput.DiscardUnknown(m) +} + +var xxx_messageInfo_ProtocolsOutput proto.InternalMessageInfo + +func (m *ProtocolsOutput) GetProtocols() []string { + if m != nil { + return m.Protocols + } + return nil +} + type DeviceInfo struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` @@ -94,7 +141,7 @@ func (m *DeviceInfo) Reset() { *m = DeviceInfo{} } func (m *DeviceInfo) String() string { return proto.CompactTextString(m) } func (*DeviceInfo) ProtoMessage() {} func (*DeviceInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{1} + return fileDescriptor_service_ae8497c40577b9fc, []int{2} } func (m *DeviceInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -148,7 +195,7 @@ func (m *AppVersionOutput) Reset() { *m = AppVersionOutput{} } func (m *AppVersionOutput) String() string { return proto.CompactTextString(m) } func (*AppVersionOutput) ProtoMessage() {} func (*AppVersionOutput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{2} + return fileDescriptor_service_ae8497c40577b9fc, []int{3} } func (m *AppVersionOutput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -195,7 +242,7 @@ func (m *PingDestination) Reset() { *m = PingDestination{} } func (m *PingDestination) String() string { return proto.CompactTextString(m) } func (*PingDestination) ProtoMessage() {} func (*PingDestination) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{3} + return fileDescriptor_service_ae8497c40577b9fc, []int{4} } func (m *PingDestination) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -243,7 +290,7 @@ func (m *ContactRequestInput) Reset() { *m = ContactRequestInput{} } func (m *ContactRequestInput) String() string { return proto.CompactTextString(m) } func (*ContactRequestInput) ProtoMessage() {} func (*ContactRequestInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{4} + return fileDescriptor_service_ae8497c40577b9fc, []int{5} } func (m *ContactRequestInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -298,7 +345,7 @@ func (m *ConversationAddMessageInput) Reset() { *m = ConversationAddMess func (m *ConversationAddMessageInput) String() string { return proto.CompactTextString(m) } func (*ConversationAddMessageInput) ProtoMessage() {} func (*ConversationAddMessageInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{5} + return fileDescriptor_service_ae8497c40577b9fc, []int{6} } func (m *ConversationAddMessageInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -352,7 +399,7 @@ func (m *EventStreamInput) Reset() { *m = EventStreamInput{} } func (m *EventStreamInput) String() string { return proto.CompactTextString(m) } func (*EventStreamInput) ProtoMessage() {} func (*EventStreamInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{6} + return fileDescriptor_service_ae8497c40577b9fc, []int{7} } func (m *EventStreamInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -403,7 +450,7 @@ func (m *EventListInput) Reset() { *m = EventListInput{} } func (m *EventListInput) String() string { return proto.CompactTextString(m) } func (*EventListInput) ProtoMessage() {} func (*EventListInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{7} + return fileDescriptor_service_ae8497c40577b9fc, []int{8} } func (m *EventListInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -458,7 +505,7 @@ func (m *EventEdge) Reset() { *m = EventEdge{} } func (m *EventEdge) String() string { return proto.CompactTextString(m) } func (*EventEdge) ProtoMessage() {} func (*EventEdge) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{8} + return fileDescriptor_service_ae8497c40577b9fc, []int{9} } func (m *EventEdge) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -513,7 +560,7 @@ func (m *EventListConnection) Reset() { *m = EventListConnection{} } func (m *EventListConnection) String() string { return proto.CompactTextString(m) } func (*EventListConnection) ProtoMessage() {} func (*EventListConnection) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{9} + return fileDescriptor_service_ae8497c40577b9fc, []int{10} } func (m *EventListConnection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -568,7 +615,7 @@ func (m *ContactListInput) Reset() { *m = ContactListInput{} } func (m *ContactListInput) String() string { return proto.CompactTextString(m) } func (*ContactListInput) ProtoMessage() {} func (*ContactListInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{10} + return fileDescriptor_service_ae8497c40577b9fc, []int{11} } func (m *ContactListInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -623,7 +670,7 @@ func (m *ContactEdge) Reset() { *m = ContactEdge{} } func (m *ContactEdge) String() string { return proto.CompactTextString(m) } func (*ContactEdge) ProtoMessage() {} func (*ContactEdge) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{11} + return fileDescriptor_service_ae8497c40577b9fc, []int{12} } func (m *ContactEdge) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -678,7 +725,7 @@ func (m *ContactListConnection) Reset() { *m = ContactListConnection{} } func (m *ContactListConnection) String() string { return proto.CompactTextString(m) } func (*ContactListConnection) ProtoMessage() {} func (*ContactListConnection) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{12} + return fileDescriptor_service_ae8497c40577b9fc, []int{13} } func (m *ContactListConnection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -733,7 +780,7 @@ func (m *ConversationListInput) Reset() { *m = ConversationListInput{} } func (m *ConversationListInput) String() string { return proto.CompactTextString(m) } func (*ConversationListInput) ProtoMessage() {} func (*ConversationListInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{13} + return fileDescriptor_service_ae8497c40577b9fc, []int{14} } func (m *ConversationListInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -788,7 +835,7 @@ func (m *ConversationEdge) Reset() { *m = ConversationEdge{} } func (m *ConversationEdge) String() string { return proto.CompactTextString(m) } func (*ConversationEdge) ProtoMessage() {} func (*ConversationEdge) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{14} + return fileDescriptor_service_ae8497c40577b9fc, []int{15} } func (m *ConversationEdge) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -843,7 +890,7 @@ func (m *ConversationListConnection) Reset() { *m = ConversationListConn func (m *ConversationListConnection) String() string { return proto.CompactTextString(m) } func (*ConversationListConnection) ProtoMessage() {} func (*ConversationListConnection) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{15} + return fileDescriptor_service_ae8497c40577b9fc, []int{16} } func (m *ConversationListConnection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -899,7 +946,7 @@ func (m *ConversationCreateInput) Reset() { *m = ConversationCreateInput func (m *ConversationCreateInput) String() string { return proto.CompactTextString(m) } func (*ConversationCreateInput) ProtoMessage() {} func (*ConversationCreateInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{16} + return fileDescriptor_service_ae8497c40577b9fc, []int{17} } func (m *ConversationCreateInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -961,7 +1008,7 @@ func (m *ConversationManageMembersInput) Reset() { *m = ConversationMana func (m *ConversationManageMembersInput) String() string { return proto.CompactTextString(m) } func (*ConversationManageMembersInput) ProtoMessage() {} func (*ConversationManageMembersInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{17} + return fileDescriptor_service_ae8497c40577b9fc, []int{18} } func (m *ConversationManageMembersInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1022,7 +1069,7 @@ func (m *Pagination) Reset() { *m = Pagination{} } func (m *Pagination) String() string { return proto.CompactTextString(m) } func (*Pagination) ProtoMessage() {} func (*Pagination) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{18} + return fileDescriptor_service_ae8497c40577b9fc, []int{19} } func (m *Pagination) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1109,7 +1156,7 @@ func (m *PageInfo) Reset() { *m = PageInfo{} } func (m *PageInfo) String() string { return proto.CompactTextString(m) } func (*PageInfo) ProtoMessage() {} func (*PageInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{19} + return fileDescriptor_service_ae8497c40577b9fc, []int{20} } func (m *PageInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1184,7 +1231,7 @@ func (m *IntegrationTestInput) Reset() { *m = IntegrationTestInput{} } func (m *IntegrationTestInput) String() string { return proto.CompactTextString(m) } func (*IntegrationTestInput) ProtoMessage() {} func (*IntegrationTestInput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{20} + return fileDescriptor_service_ae8497c40577b9fc, []int{21} } func (m *IntegrationTestInput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1235,7 +1282,7 @@ func (m *IntegrationTestOutput) Reset() { *m = IntegrationTestOutput{} } func (m *IntegrationTestOutput) String() string { return proto.CompactTextString(m) } func (*IntegrationTestOutput) ProtoMessage() {} func (*IntegrationTestOutput) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{21} + return fileDescriptor_service_ae8497c40577b9fc, []int{22} } func (m *IntegrationTestOutput) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1310,7 +1357,7 @@ func (m *Void) Reset() { *m = Void{} } func (m *Void) String() string { return proto.CompactTextString(m) } func (*Void) ProtoMessage() {} func (*Void) Descriptor() ([]byte, []int) { - return fileDescriptor_service_f43a9866e909a19c, []int{22} + return fileDescriptor_service_ae8497c40577b9fc, []int{23} } func (m *Void) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1348,6 +1395,7 @@ func (m *Void) GetT() bool { func init() { proto.RegisterType((*DeviceInfosOutput)(nil), "berty.node.DeviceInfosOutput") + proto.RegisterType((*ProtocolsOutput)(nil), "berty.node.ProtocolsOutput") proto.RegisterType((*DeviceInfo)(nil), "berty.node.DeviceInfo") proto.RegisterType((*AppVersionOutput)(nil), "berty.node.AppVersionOutput") proto.RegisterType((*PingDestination)(nil), "berty.node.PingDestination") @@ -1384,6 +1432,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type ServiceClient interface { + // return node current ID + ID(ctx context.Context, in *Void, opts ...grpc.CallOption) (*p2p.Peer, error) // yield new events in real-time EventStream(ctx context.Context, in *EventStreamInput, opts ...grpc.CallOption) (Service_EventStreamClient, error) // list old events @@ -1407,12 +1457,15 @@ type ServiceClient interface { HandleEvent(ctx context.Context, in *p2p.Event, opts ...grpc.CallOption) (*Void, error) GenerateFakeData(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) RunIntegrationTests(ctx context.Context, in *IntegrationTestInput, opts ...grpc.CallOption) (*IntegrationTestOutput, error) - // Yield new peers in real-time - MonitorPeers(ctx context.Context, in *Void, opts ...grpc.CallOption) (Service_MonitorPeersClient, error) - Peers(ctx context.Context, in *Void, opts ...grpc.CallOption) (*p2p.Peers, error) DebugPing(ctx context.Context, in *PingDestination, opts ...grpc.CallOption) (*Void, error) DeviceInfos(ctx context.Context, in *Void, opts ...grpc.CallOption) (*DeviceInfosOutput, error) AppVersion(ctx context.Context, in *Void, opts ...grpc.CallOption) (*AppVersionOutput, error) + Peers(ctx context.Context, in *Void, opts ...grpc.CallOption) (*p2p.Peers, error) + Protocols(ctx context.Context, in *p2p.Peer, opts ...grpc.CallOption) (*ProtocolsOutput, error) + // Yield bandwidth in real-time + MonitorBandwidth(ctx context.Context, in *p2p.BandwidthStats, opts ...grpc.CallOption) (Service_MonitorBandwidthClient, error) + // Yield new peers in real-time + MonitorPeers(ctx context.Context, in *Void, opts ...grpc.CallOption) (Service_MonitorPeersClient, error) Panic(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) } @@ -1424,6 +1477,15 @@ func NewServiceClient(cc *grpc.ClientConn) ServiceClient { return &serviceClient{cc} } +func (c *serviceClient) ID(ctx context.Context, in *Void, opts ...grpc.CallOption) (*p2p.Peer, error) { + out := new(p2p.Peer) + err := c.cc.Invoke(ctx, "/berty.node.Service/ID", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *serviceClient) EventStream(ctx context.Context, in *EventStreamInput, opts ...grpc.CallOption) (Service_EventStreamClient, error) { stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[0], "/berty.node.Service/EventStream", opts...) if err != nil { @@ -1687,12 +1749,57 @@ func (c *serviceClient) RunIntegrationTests(ctx context.Context, in *Integration return out, nil } -func (c *serviceClient) MonitorPeers(ctx context.Context, in *Void, opts ...grpc.CallOption) (Service_MonitorPeersClient, error) { - stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[4], "/berty.node.Service/MonitorPeers", opts...) +func (c *serviceClient) DebugPing(ctx context.Context, in *PingDestination, opts ...grpc.CallOption) (*Void, error) { + out := new(Void) + err := c.cc.Invoke(ctx, "/berty.node.Service/DebugPing", in, out, opts...) if err != nil { return nil, err } - x := &serviceMonitorPeersClient{stream} + return out, nil +} + +func (c *serviceClient) DeviceInfos(ctx context.Context, in *Void, opts ...grpc.CallOption) (*DeviceInfosOutput, error) { + out := new(DeviceInfosOutput) + err := c.cc.Invoke(ctx, "/berty.node.Service/DeviceInfos", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) AppVersion(ctx context.Context, in *Void, opts ...grpc.CallOption) (*AppVersionOutput, error) { + out := new(AppVersionOutput) + err := c.cc.Invoke(ctx, "/berty.node.Service/AppVersion", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Peers(ctx context.Context, in *Void, opts ...grpc.CallOption) (*p2p.Peers, error) { + out := new(p2p.Peers) + err := c.cc.Invoke(ctx, "/berty.node.Service/Peers", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) Protocols(ctx context.Context, in *p2p.Peer, opts ...grpc.CallOption) (*ProtocolsOutput, error) { + out := new(ProtocolsOutput) + err := c.cc.Invoke(ctx, "/berty.node.Service/Protocols", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) MonitorBandwidth(ctx context.Context, in *p2p.BandwidthStats, opts ...grpc.CallOption) (Service_MonitorBandwidthClient, error) { + stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[4], "/berty.node.Service/MonitorBandwidth", opts...) + if err != nil { + return nil, err + } + x := &serviceMonitorBandwidthClient{stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -1702,57 +1809,53 @@ func (c *serviceClient) MonitorPeers(ctx context.Context, in *Void, opts ...grpc return x, nil } -type Service_MonitorPeersClient interface { - Recv() (*p2p.Peer, error) +type Service_MonitorBandwidthClient interface { + Recv() (*p2p.BandwidthStats, error) grpc.ClientStream } -type serviceMonitorPeersClient struct { +type serviceMonitorBandwidthClient struct { grpc.ClientStream } -func (x *serviceMonitorPeersClient) Recv() (*p2p.Peer, error) { - m := new(p2p.Peer) +func (x *serviceMonitorBandwidthClient) Recv() (*p2p.BandwidthStats, error) { + m := new(p2p.BandwidthStats) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } return m, nil } -func (c *serviceClient) Peers(ctx context.Context, in *Void, opts ...grpc.CallOption) (*p2p.Peers, error) { - out := new(p2p.Peers) - err := c.cc.Invoke(ctx, "/berty.node.Service/Peers", in, out, opts...) +func (c *serviceClient) MonitorPeers(ctx context.Context, in *Void, opts ...grpc.CallOption) (Service_MonitorPeersClient, error) { + stream, err := c.cc.NewStream(ctx, &_Service_serviceDesc.Streams[5], "/berty.node.Service/MonitorPeers", opts...) if err != nil { return nil, err } - return out, nil -} - -func (c *serviceClient) DebugPing(ctx context.Context, in *PingDestination, opts ...grpc.CallOption) (*Void, error) { - out := new(Void) - err := c.cc.Invoke(ctx, "/berty.node.Service/DebugPing", in, out, opts...) - if err != nil { + x := &serviceMonitorPeersClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } - return out, nil -} - -func (c *serviceClient) DeviceInfos(ctx context.Context, in *Void, opts ...grpc.CallOption) (*DeviceInfosOutput, error) { - out := new(DeviceInfosOutput) - err := c.cc.Invoke(ctx, "/berty.node.Service/DeviceInfos", in, out, opts...) - if err != nil { + if err := x.ClientStream.CloseSend(); err != nil { return nil, err } - return out, nil + return x, nil } -func (c *serviceClient) AppVersion(ctx context.Context, in *Void, opts ...grpc.CallOption) (*AppVersionOutput, error) { - out := new(AppVersionOutput) - err := c.cc.Invoke(ctx, "/berty.node.Service/AppVersion", in, out, opts...) - if err != nil { +type Service_MonitorPeersClient interface { + Recv() (*p2p.Peer, error) + grpc.ClientStream +} + +type serviceMonitorPeersClient struct { + grpc.ClientStream +} + +func (x *serviceMonitorPeersClient) Recv() (*p2p.Peer, error) { + m := new(p2p.Peer) + if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } - return out, nil + return m, nil } func (c *serviceClient) Panic(ctx context.Context, in *Void, opts ...grpc.CallOption) (*Void, error) { @@ -1766,6 +1869,8 @@ func (c *serviceClient) Panic(ctx context.Context, in *Void, opts ...grpc.CallOp // ServiceServer is the server API for Service service. type ServiceServer interface { + // return node current ID + ID(context.Context, *Void) (*p2p.Peer, error) // yield new events in real-time EventStream(*EventStreamInput, Service_EventStreamServer) error // list old events @@ -1789,12 +1894,15 @@ type ServiceServer interface { HandleEvent(context.Context, *p2p.Event) (*Void, error) GenerateFakeData(context.Context, *Void) (*Void, error) RunIntegrationTests(context.Context, *IntegrationTestInput) (*IntegrationTestOutput, error) - // Yield new peers in real-time - MonitorPeers(*Void, Service_MonitorPeersServer) error - Peers(context.Context, *Void) (*p2p.Peers, error) DebugPing(context.Context, *PingDestination) (*Void, error) DeviceInfos(context.Context, *Void) (*DeviceInfosOutput, error) AppVersion(context.Context, *Void) (*AppVersionOutput, error) + Peers(context.Context, *Void) (*p2p.Peers, error) + Protocols(context.Context, *p2p.Peer) (*ProtocolsOutput, error) + // Yield bandwidth in real-time + MonitorBandwidth(*p2p.BandwidthStats, Service_MonitorBandwidthServer) error + // Yield new peers in real-time + MonitorPeers(*Void, Service_MonitorPeersServer) error Panic(context.Context, *Void) (*Void, error) } @@ -1802,6 +1910,24 @@ func RegisterServiceServer(s *grpc.Server, srv ServiceServer) { s.RegisterService(&_Service_serviceDesc, srv) } +func _Service_ID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Void) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).ID(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/berty.node.Service/ID", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).ID(ctx, req.(*Void)) + } + return interceptor(ctx, in, info, handler) +} + func _Service_EventStream_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(EventStreamInput) if err := stream.RecvMsg(m); err != nil { @@ -2156,99 +2282,138 @@ func _Service_RunIntegrationTests_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } -func _Service_MonitorPeers_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(Void) - if err := stream.RecvMsg(m); err != nil { - return err +func _Service_DebugPing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingDestination) + if err := dec(in); err != nil { + return nil, err } - return srv.(ServiceServer).MonitorPeers(m, &serviceMonitorPeersServer{stream}) -} - -type Service_MonitorPeersServer interface { - Send(*p2p.Peer) error - grpc.ServerStream -} - -type serviceMonitorPeersServer struct { - grpc.ServerStream -} - -func (x *serviceMonitorPeersServer) Send(m *p2p.Peer) error { - return x.ServerStream.SendMsg(m) + if interceptor == nil { + return srv.(ServiceServer).DebugPing(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/berty.node.Service/DebugPing", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).DebugPing(ctx, req.(*PingDestination)) + } + return interceptor(ctx, in, info, handler) } -func _Service_Peers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Service_DeviceInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Void) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ServiceServer).Peers(ctx, in) + return srv.(ServiceServer).DeviceInfos(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/berty.node.Service/Peers", + FullMethod: "/berty.node.Service/DeviceInfos", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).Peers(ctx, req.(*Void)) + return srv.(ServiceServer).DeviceInfos(ctx, req.(*Void)) } return interceptor(ctx, in, info, handler) } -func _Service_DebugPing_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PingDestination) +func _Service_AppVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Void) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ServiceServer).DebugPing(ctx, in) + return srv.(ServiceServer).AppVersion(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/berty.node.Service/DebugPing", + FullMethod: "/berty.node.Service/AppVersion", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).DebugPing(ctx, req.(*PingDestination)) + return srv.(ServiceServer).AppVersion(ctx, req.(*Void)) } return interceptor(ctx, in, info, handler) } -func _Service_DeviceInfos_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Service_Peers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Void) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ServiceServer).DeviceInfos(ctx, in) + return srv.(ServiceServer).Peers(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/berty.node.Service/DeviceInfos", + FullMethod: "/berty.node.Service/Peers", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).DeviceInfos(ctx, req.(*Void)) + return srv.(ServiceServer).Peers(ctx, req.(*Void)) } return interceptor(ctx, in, info, handler) } -func _Service_AppVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Void) +func _Service_Protocols_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(p2p.Peer) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ServiceServer).AppVersion(ctx, in) + return srv.(ServiceServer).Protocols(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/berty.node.Service/AppVersion", + FullMethod: "/berty.node.Service/Protocols", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ServiceServer).AppVersion(ctx, req.(*Void)) + return srv.(ServiceServer).Protocols(ctx, req.(*p2p.Peer)) } return interceptor(ctx, in, info, handler) } +func _Service_MonitorBandwidth_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(p2p.BandwidthStats) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ServiceServer).MonitorBandwidth(m, &serviceMonitorBandwidthServer{stream}) +} + +type Service_MonitorBandwidthServer interface { + Send(*p2p.BandwidthStats) error + grpc.ServerStream +} + +type serviceMonitorBandwidthServer struct { + grpc.ServerStream +} + +func (x *serviceMonitorBandwidthServer) Send(m *p2p.BandwidthStats) error { + return x.ServerStream.SendMsg(m) +} + +func _Service_MonitorPeers_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(Void) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ServiceServer).MonitorPeers(m, &serviceMonitorPeersServer{stream}) +} + +type Service_MonitorPeersServer interface { + Send(*p2p.Peer) error + grpc.ServerStream +} + +type serviceMonitorPeersServer struct { + grpc.ServerStream +} + +func (x *serviceMonitorPeersServer) Send(m *p2p.Peer) error { + return x.ServerStream.SendMsg(m) +} + func _Service_Panic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Void) if err := dec(in); err != nil { @@ -2271,6 +2436,10 @@ var _Service_serviceDesc = grpc.ServiceDesc{ ServiceName: "berty.node.Service", HandlerType: (*ServiceServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "ID", + Handler: _Service_ID_Handler, + }, { MethodName: "GetEvent", Handler: _Service_GetEvent_Handler, @@ -2331,10 +2500,6 @@ var _Service_serviceDesc = grpc.ServiceDesc{ MethodName: "RunIntegrationTests", Handler: _Service_RunIntegrationTests_Handler, }, - { - MethodName: "Peers", - Handler: _Service_Peers_Handler, - }, { MethodName: "DebugPing", Handler: _Service_DebugPing_Handler, @@ -2347,6 +2512,14 @@ var _Service_serviceDesc = grpc.ServiceDesc{ MethodName: "AppVersion", Handler: _Service_AppVersion_Handler, }, + { + MethodName: "Peers", + Handler: _Service_Peers_Handler, + }, + { + MethodName: "Protocols", + Handler: _Service_Protocols_Handler, + }, { MethodName: "Panic", Handler: _Service_Panic_Handler, @@ -2373,6 +2546,11 @@ var _Service_serviceDesc = grpc.ServiceDesc{ Handler: _Service_ConversationList_Handler, ServerStreams: true, }, + { + StreamName: "MonitorBandwidth", + Handler: _Service_MonitorBandwidth_Handler, + ServerStreams: true, + }, { StreamName: "MonitorPeers", Handler: _Service_MonitorPeers_Handler, @@ -2415,6 +2593,42 @@ func (m *DeviceInfosOutput) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ProtocolsOutput) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ProtocolsOutput) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Protocols) > 0 { + for _, s := range m.Protocols { + dAtA[i] = 0xa + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + func (m *DeviceInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -3335,6 +3549,24 @@ func (m *DeviceInfosOutput) Size() (n int) { return n } +func (m *ProtocolsOutput) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Protocols) > 0 { + for _, s := range m.Protocols { + l = len(s) + n += 1 + l + sovService(uint64(l)) + } + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func (m *DeviceInfo) Size() (n int) { if m == nil { return 0 @@ -3892,6 +4124,86 @@ func (m *DeviceInfosOutput) Unmarshal(dAtA []byte) error { } return nil } +func (m *ProtocolsOutput) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ProtocolsOutput: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProtocolsOutput: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Protocols", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowService + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthService + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Protocols = append(m.Protocols, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipService(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthService + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *DeviceInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -6574,105 +6886,111 @@ var ( ErrIntOverflowService = fmt.Errorf("proto: integer overflow") ) -func init() { proto.RegisterFile("api/node/service.proto", fileDescriptor_service_f43a9866e909a19c) } - -var fileDescriptor_service_f43a9866e909a19c = []byte{ - // 1547 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x4b, 0x73, 0xdb, 0xd4, - 0x17, 0xaf, 0x5a, 0x3b, 0xb1, 0x8f, 0x93, 0xc6, 0xbd, 0x79, 0xd4, 0x71, 0xd3, 0x3c, 0xf4, 0xff, - 0x0f, 0x84, 0xd0, 0xda, 0x25, 0x61, 0x78, 0x4d, 0x87, 0x99, 0xbc, 0x08, 0x19, 0x08, 0xa4, 0x6a, - 0xe8, 0xa2, 0x1b, 0x8f, 0x2c, 0x1d, 0x2b, 0xa2, 0xb6, 0xa4, 0x4a, 0x57, 0x9e, 0x64, 0xba, 0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x05, 0x68, 0x8a, 0xda, - 0x71, 0x53, 0xb3, 0x5d, 0x6c, 0x86, 0xdf, 0xcd, 0xda, 0x63, 0x7c, 0x96, 0xd9, 0xf8, 0x37, 0x00, - 0x00, 0xff, 0xff, 0x83, 0xa6, 0xa1, 0x5d, 0x4a, 0x13, 0x00, 0x00, +func init() { proto.RegisterFile("api/node/service.proto", fileDescriptor_service_ae8497c40577b9fc) } + +var fileDescriptor_service_ae8497c40577b9fc = []byte{ + // 1643 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x6e, 0x1b, 0x47, + 0x12, 0xf6, 0xd8, 0xa4, 0x44, 0x16, 0x25, 0x8b, 0x6e, 0xfd, 0x98, 0xa4, 0x65, 0xfd, 0xcc, 0x2e, + 0x76, 0xb5, 0x5a, 0x9b, 0xf4, 0x52, 0x8b, 0xdd, 0x24, 0x30, 0x02, 0x48, 0xa2, 0xa2, 0x08, 0x89, + 0x12, 0x79, 0xa4, 0xf8, 0x60, 0x04, 0x20, 0x86, 0x33, 0x45, 0x72, 0x62, 0x72, 0x66, 0x3c, 0xd3, + 0x64, 0x24, 0xf8, 0x90, 0x5c, 0x02, 0x38, 0x97, 0x20, 0xc7, 0x1c, 0xf2, 0x14, 0x01, 0x92, 0x67, + 0xf0, 0x31, 0xf0, 0x03, 0x24, 0x81, 0x73, 0xcc, 0x45, 0xb9, 0xe6, 0x14, 0x74, 0x4f, 0xcf, 0x2f, + 0x87, 0xb4, 0x0d, 0x39, 0x27, 0xb1, 0xab, 0xab, 0xbe, 0xea, 0xfa, 0xaa, 0xa6, 0xab, 0xd4, 0xb0, + 0xa4, 0xda, 0x46, 0xcd, 0xb4, 0x74, 0xac, 0xb9, 0xe8, 0x0c, 0x0d, 0x0d, 0xab, 0xb6, 0x63, 0x51, + 0x8b, 0x40, 0x0b, 0x1d, 0x7a, 0x56, 0x65, 0x3b, 0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cf, 0x57, 0xa4, 0x1f, 0x9f, 0xaf, + 0x48, 0xbf, 0x3c, 0x5f, 0x91, 0xbe, 0xf9, 0x75, 0xe5, 0xd2, 0x83, 0x92, 0xa7, 0x4d, 0x51, 0xeb, + 0xd6, 0x34, 0xcb, 0xc1, 0x9a, 0xff, 0xae, 0xd8, 0x9a, 0xe2, 0x33, 0xda, 0xd6, 0x9f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0xbe, 0x9f, 0x48, 0xa0, 0x6a, 0x14, 0x00, 0x00, } diff --git a/core/api/node/service.proto b/core/api/node/service.proto index 769ec27734..cecdddba4e 100644 --- a/core/api/node/service.proto +++ b/core/api/node/service.proto @@ -4,6 +4,7 @@ package berty.node; import "api/protobuf/graphql/graphql.proto"; import "api/p2p/event.proto"; +import "api/p2p/metrics.proto"; import "api/p2p/peer.proto"; import "entity/contact.proto"; import "entity/conversation.proto"; @@ -16,6 +17,10 @@ import "google/protobuf/timestamp.proto"; option go_package = "berty.tech/core/api/node"; service Service { + // return node current ID + rpc ID(Void) returns (berty.p2p.Peer) { + option (gql.graphql_type) = "Query"; + }; // // Events @@ -105,32 +110,36 @@ service Service { option (gql.graphql_type) = "Mutation"; }; - // - // Metrics - // + rpc DebugPing(PingDestination) returns (Void) {}; - // Yield new peers in real-time - rpc MonitorPeers(Void) returns (stream p2p.Peer) { - option (gql.graphql_type) = "Subscription"; + rpc DeviceInfos(Void) returns (DeviceInfosOutput) { + option (gql.graphql_type) = "Query"; + }; + + rpc AppVersion(Void) returns (AppVersionOutput) { + option (gql.graphql_type) = "Query"; }; rpc Peers(Void) returns (p2p.Peers) { option (gql.graphql_type) = "Query"; }; - // // yield new connection in real-time - // rpc MonitorConnection(EventStreamInput) returns (stream libp2p.Peer) { - // option (gql.graphql_type) = "Subscription"; - // }; + rpc Protocols(p2p.Peer) returns (ProtocolsOutput) { + option (gql.graphql_type) = "Query"; + }; - rpc DebugPing(PingDestination) returns (Void) {}; + // + // Metrics + // - rpc DeviceInfos(Void) returns (DeviceInfosOutput) { - option (gql.graphql_type) = "Query"; + // Yield bandwidth in real-time + rpc MonitorBandwidth(berty.p2p.BandwidthStats) returns (stream berty.p2p.BandwidthStats) { + option (gql.graphql_type) = "Subscription"; }; - rpc AppVersion(Void) returns (AppVersionOutput) { - option (gql.graphql_type) = "Query"; + // Yield new peers in real-time + rpc MonitorPeers(Void) returns (stream p2p.Peer) { + option (gql.graphql_type) = "Subscription"; }; rpc Panic(Void) returns (Void) { @@ -143,6 +152,10 @@ message DeviceInfosOutput { repeated DeviceInfo infos = 1; } +message ProtocolsOutput { + repeated string protocols = 1; +}; + message DeviceInfo { string key = 1; string value = 2; diff --git a/core/go.mod b/core/go.mod index fc713dabb4..f38e3aa213 100644 --- a/core/go.mod +++ b/core/go.mod @@ -122,7 +122,7 @@ require ( github.com/uber-go/atomic v1.3.2 // indirect github.com/uber/jaeger-client-go v2.15.0+incompatible github.com/uber/jaeger-lib v1.5.0 // indirect - github.com/vektah/gqlparser v0.0.0-20181002002754-f119686bf1d4 + github.com/vektah/gqlparser v0.0.0-20181002002754-f119686bf1d4 // indirect github.com/whyrusleeping/base32 v0.0.0-20170828182744-c30ac30633cc // indirect github.com/whyrusleeping/go-keyspace v0.0.0-20160322163242-5b898ac5add1 // indirect github.com/whyrusleeping/go-logging v0.0.0-20170515211332-0457bb6b88fc diff --git a/core/network/driver.go b/core/network/driver.go index 605cd73a80..6cdeec2d2e 100644 --- a/core/network/driver.go +++ b/core/network/driver.go @@ -3,6 +3,7 @@ package network import ( "context" "net" + "time" "berty.tech/core/api/p2p" protocol "github.com/libp2p/go-libp2p-protocol" @@ -13,12 +14,23 @@ type Metrics interface { Peers() *p2p.Peers // Monitor connected/disconnected peers - MonitorPeers(func(*p2p.Peer) error) + MonitorPeers(func(*p2p.Peer, error) error) - // MonitorBandwith(func(*p2p.Peers)) + // Monitor bandwidth globally with the given interval + MonitorBandwidth(time.Duration, func(*p2p.BandwidthStats, error) error) + + // Monitor bandwidth of a specific protocol with the given protocol id + // and interval + MonitorBandwidthProtocol(string, time.Duration, func(*p2p.BandwidthStats, error) error) + + // Monitor bandwidth of a specific peer with the given peer id and interval + MonitorBandwidthPeer(string, time.Duration, func(*p2p.BandwidthStats, error) error) } type Driver interface { + // Return driver current id + ID() *p2p.Peer + // Emit sends an envelope to a channel Emit(context.Context, *p2p.Envelope) error @@ -37,6 +49,9 @@ type Driver interface { // Start start service listener Start() error + // Return the supported protocols of the given peer + Protocols(*p2p.Peer) ([]string, error) + // Close cleanups things Close() error } diff --git a/core/network/p2p/driver.go b/core/network/p2p/driver.go index c6468a2306..897d4069ef 100644 --- a/core/network/p2p/driver.go +++ b/core/network/p2p/driver.go @@ -247,6 +247,28 @@ func (d *Driver) getPeerInfo(addr string) (*pstore.PeerInfo, error) { return pstore.InfoFromP2pAddr(iaddr.Multiaddr()) } +func (d *Driver) Protocols(p *p2p.Peer) ([]string, error) { + peerid, err := peer.IDB58Decode(p.ID) + if err != nil { + return nil, fmt.Errorf("get protocols error: `%s`", err) + } + + return d.host.Peerstore().GetProtocols(peerid) +} + +func (d *Driver) ID() *p2p.Peer { + addrs := make([]string, len(d.host.Addrs())) + for i, addr := range d.host.Addrs() { + addrs[i] = addr.String() + } + + return &p2p.Peer{ + ID: d.host.ID().Pretty(), + Addrs: addrs, + Connection: p2p.ConnectionType_CONNECTED, + } +} + func (d *Driver) Close() error { // FIXME: save cache to speedup next connections var err error diff --git a/core/network/p2p/metrics.go b/core/network/p2p/metrics.go index 33c29c04b4..6010afb97b 100644 --- a/core/network/p2p/metrics.go +++ b/core/network/p2p/metrics.go @@ -1,13 +1,18 @@ package p2p import ( + "fmt" "sync" + "time" host "github.com/libp2p/go-libp2p-host" + bw "github.com/libp2p/go-libp2p-metrics" inet "github.com/libp2p/go-libp2p-net" peer "github.com/libp2p/go-libp2p-peer" pstore "github.com/libp2p/go-libp2p-peerstore" + protocol "github.com/libp2p/go-libp2p-protocol" ma "github.com/multiformats/go-multiaddr" + "go.uber.org/zap" "berty.tech/core/api/p2p" "berty.tech/core/network" @@ -19,9 +24,10 @@ var _ network.Metrics = (*Metrics)(nil) type Metrics struct { host host.Host - peersHandlers []func(*p2p.Peer) error + peersHandlers []func(*p2p.Peer, error) error muHPeers sync.Mutex + bw *bw.BandwidthCounter driver *Driver } @@ -29,7 +35,8 @@ func NewMetrics(d *Driver) network.Metrics { m := &Metrics{ host: d.host, driver: d, - peersHandlers: make([]func(*p2p.Peer) error, 0), + peersHandlers: make([]func(*p2p.Peer, error) error, 0), + bw: bw.NewBandwidthCounter(), } m.host.Network().Notify(m) @@ -49,19 +56,91 @@ func (m *Metrics) Peers() *p2p.Peers { return pis } -func (m *Metrics) MonitorPeers(handler func(*p2p.Peer) error) { +func (m *Metrics) bandwidthToStats(b bw.Stats) *p2p.BandwidthStats { + return &p2p.BandwidthStats{ + TotalIn: b.TotalIn, + TotalOut: b.TotalOut, + RateIn: b.RateIn, + RateOut: b.RateOut, + } +} + +func (m *Metrics) MonitorPeers(handler func(*p2p.Peer, error) error) { m.muHPeers.Lock() m.peersHandlers = append(m.peersHandlers, handler) m.muHPeers.Unlock() } +func (m *Metrics) MonitorBandwidth(interval time.Duration, handler func(*p2p.BandwidthStats, error) error) { + ticker := time.NewTicker(interval) + go func() { + for { + <-ticker.C + out := m.bw.GetBandwidthTotals() + + logger().Debug("monitoring bandwidth", zap.Int64("in", out.TotalIn), zap.Int64("out", out.TotalOut)) + + stats := m.bandwidthToStats(out) + stats.Type = p2p.MetricsType_GLOBAL + if err := handler(stats, nil); err != nil { + return + } + } + }() +} + +func (m *Metrics) MonitorBandwidthProtocol(id string, interval time.Duration, handler func(*p2p.BandwidthStats, error) error) { + pid := protocol.ID(id) + ticker := time.NewTicker(interval) + go func() { + for { + <-ticker.C + out := m.bw.GetBandwidthForProtocol(pid) + + logger().Debug("monitoring bandwidth protocol", zap.String("protocol", id), zap.Int64("in", out.TotalIn), zap.Int64("out", out.TotalOut)) + + stats := m.bandwidthToStats(out) + stats.Type = p2p.MetricsType_PROTOCOL + stats.ID = id + if err := handler(stats, nil); err != nil { + return + } + } + }() +} + +func (m *Metrics) MonitorBandwidthPeer(id string, interval time.Duration, handler func(*p2p.BandwidthStats, error) error) { + peerid, err := peer.IDFromString(id) + if err != nil { + handler(nil, fmt.Errorf("monitor bandwidth peer", err)) + return + } + + ticker := time.NewTicker(interval) + go func() { + for { + <-ticker.C + out := m.bw.GetBandwidthForPeer(peerid) + + logger().Debug("monitor bandwidth peer", zap.String("peer id", id), zap.Int64("in", out.TotalIn), zap.Int64("out", out.TotalOut)) + + stats := m.bandwidthToStats(out) + stats.Type = p2p.MetricsType_PEER + stats.ID = id + if err := handler(stats, nil); err != nil { + return + } + } + }() +} + func (m *Metrics) handlePeer(id peer.ID) { pi := m.host.Peerstore().PeerInfo(id) peer := m.peerInfoToPeer(pi) m.muHPeers.Lock() for i, h := range m.peersHandlers { - if err := h(peer); err != nil { + if err := h(peer, nil); err != nil { m.peersHandlers = append(m.peersHandlers[:i], m.peersHandlers[i+1:]...) } } diff --git a/core/node/p2papi.go b/core/node/p2papi.go index baeada33dd..506553d061 100644 --- a/core/node/p2papi.go +++ b/core/node/p2papi.go @@ -14,6 +14,7 @@ import ( "crypto/x509" + "berty.tech/core/api/node" "berty.tech/core/api/p2p" "berty.tech/core/crypto/keypair" ) @@ -25,7 +26,36 @@ func WithP2PGrpcServer(gs *grpc.Server) NewNodeOption { } } -func (n *Node) HandleEnvelope(ctx context.Context, input *p2p.Envelope) (*p2p.Void, error) { +func (n *Node) ID(ctx context.Context, _ *node.Void) (*p2p.Peer, error) { + return n.networkDriver.ID(), nil +} + +func (n *Node) Protocols(ctx context.Context, p *p2p.Peer) (*node.ProtocolsOutput, error) { + pids, err := n.networkDriver.Protocols(p) + if err != nil { + return nil, err + } + + return &node.ProtocolsOutput{ + Protocols: pids, + }, nil +} + +ffunc (n *Node) ID(ctx context.Context, _ *node.Void) (*p2p.Peer, error) { + return n.networkDriver.ID(), nil +} + +func (n *Node) Protocols(ctx context.Context, p *p2p.Peer) (*node.ProtocolsOutput, error) { + pids, err := n.networkDriver.Protocols(p) + if err != nil { + return nil, err + } + + return &node.ProtocolsOutput{ + Protocols: pids, + }, nil +} +unc (n *Node) HandleEnvelope(ctx context.Context, input *p2p.Envelope) (*p2p.Void, error) { n.asyncWaitGroup.Add(1) defer n.asyncWaitGroup.Done() return &p2p.Void{}, n.handleEnvelope(ctx, input)