From 4fca4d93ea56297c68bdcd7bec24c576f469849c Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 7 Apr 2022 12:27:24 +0800 Subject: [PATCH] rebuild proto files and import google.golang.org/protobuf --- go.mod | 10 +- go.sum | 31 +++++ pkg/cmd/run.go | 29 ++++- pkg/grpc/server.go | 17 +++ pkg/pb/bbgo.proto | 319 +++++++++++++++++++++++---------------------- 5 files changed, 244 insertions(+), 162 deletions(-) diff --git a/go.mod b/go.mod index 7ae7ef8c4..16e45eea0 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( go.uber.org/multierr v1.7.0 golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 gonum.org/v1/gonum v0.8.1 - google.golang.org/protobuf v1.27.1 + google.golang.org/protobuf v1.28.0 gopkg.in/tucnak/telebot.v2 v2.5.0 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) @@ -101,11 +101,13 @@ require ( go.opentelemetry.io/otel/trace v0.19.0 // indirect go.uber.org/atomic v1.9.0 // indirect golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad // indirect - golang.org/x/net v0.0.0-20211205041911-012df41ee64c // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect - golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect + golang.org/x/net v0.0.0-20220403103023-749bd193bc2b // indirect + golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect golang.org/x/tools v0.1.9 // indirect + google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf // indirect + google.golang.org/grpc v1.45.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect nhooyr.io/websocket v1.8.7 // indirect diff --git a/go.sum b/go.sum index 59b7688d3..83788f411 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,7 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -75,6 +76,11 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482 h1:5/aEFreBh9hH/0G+33xtczJCvMaulqsm9nDuu2BZUEo= @@ -98,6 +104,8 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU= github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw= @@ -211,6 +219,7 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -223,6 +232,7 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -397,6 +407,7 @@ github.com/rifflock/lfshook v0.0.0-20180920164130-b9218ef580f5/go.mod h1:GEXHk5H github.com/robfig/cron/v3 v3.0.0 h1:kQ6Cb7aHOHTSzNVNEhmp8EcWKLb4CbiMW9h9VyIhO4E= github.com/robfig/cron/v3 v3.0.0/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -489,6 +500,7 @@ go.opentelemetry.io/otel/oteltest v0.19.0 h1:YVfA0ByROYqTwOxqHVZYZExzEpfZor+MU1r go.opentelemetry.io/otel/oteltest v0.19.0/go.mod h1:tI4yxwh8U21v7JD6R3BcA/2+RBoTKFexE/PJ/nSO7IA= go.opentelemetry.io/otel/trace v0.19.0 h1:1ucYlenXIDA1OlHVLDZKX0ObXV5RLaq06DtUKz5e5zc= go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bjBWZQA5DXz/qg= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= @@ -579,10 +591,13 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211205041911-012df41ee64c h1:7SfqwP5fxEtl/P02w5IhKc86ziJ+A25yFrkVgoy2FT8= golang.org/x/net v0.0.0-20211205041911-012df41ee64c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220403103023-749bd193bc2b h1:vI32FkLJNAWtGD4BwkThwEy6XS7ZLLMHkSkYfF8M0W0= +golang.org/x/net v0.0.0-20220403103023-749bd193bc2b/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -645,20 +660,26 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12 h1:QyVthZKMsyaQwBTJE04jdNN0Pp5Fn9Qga0mrgxyERQM= +golang.org/x/sys v0.0.0-20220406163625-3f8b81556e12/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= @@ -772,12 +793,15 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf h1:JTjwKJX9erVpsw17w+OIPP7iAgEkN/r8urhWSunEDTs= +google.golang.org/genproto v0.0.0-20220405205423-9d709892a2bf/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -790,6 +814,10 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -804,6 +832,8 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -824,6 +854,7 @@ gopkg.in/tucnak/telebot.v2 v2.5.0/go.mod h1:BgaIIx50PSRS9pG59JH+geT82cfvoJU/IaI5 gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index 9880f2668..0cc2cbeb9 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -17,6 +17,7 @@ import ( "github.com/c9s/bbgo/pkg/bbgo" "github.com/c9s/bbgo/pkg/cmd/cmdutil" + "github.com/c9s/bbgo/pkg/grpc" "github.com/c9s/bbgo/pkg/server" ) @@ -148,6 +149,19 @@ func runConfig(basectx context.Context, cmd *cobra.Command, userConfig *bbgo.Con enableWebServer = true } + enableGrpc, err := cmd.Flags().GetBool("enable-grpc") + if err != nil { + return err + } + + grpcBind, err := cmd.Flags().GetString("grpc-bind") + if err != nil { + return err + } + + _ = grpcBind + _ = enableGrpc + ctx, cancelTrading := context.WithCancel(basectx) defer cancelTrading() @@ -188,7 +202,20 @@ func runConfig(basectx context.Context, cmd *cobra.Command, userConfig *bbgo.Con } if err := s.Run(ctx, webServerBind); err != nil { - log.WithError(err).Errorf("server error") + log.WithError(err).Errorf("http server bind error") + } + }() + } + + if enableGrpc { + go func() { + s := &grpc.Server{ + Config: userConfig, + Environ: environ, + Trader: trader, + } + if err := s.Run(grpcBind); err != nil { + log.WithError(err).Errorf("grpc server bind error") } }() } diff --git a/pkg/grpc/server.go b/pkg/grpc/server.go index fad3a9757..7d8495928 100644 --- a/pkg/grpc/server.go +++ b/pkg/grpc/server.go @@ -1,5 +1,22 @@ package grpc +import ( + "github.com/c9s/bbgo/pkg/bbgo" + "github.com/c9s/bbgo/pkg/pb" +) + +import "google.golang.org/grpc" +type Server struct { + Config *bbgo.Config + Environ *bbgo.Environment + Trader *bbgo.Trader +} +func (s *Server) Run(bind string) error { + var grpcServer = grpc.NewServer() + _ = grpcServer + _ = pb.QueryTradesResponse{} + return nil +} diff --git a/pkg/pb/bbgo.proto b/pkg/pb/bbgo.proto index 3e7ca9571..9a29f58b9 100644 --- a/pkg/pb/bbgo.proto +++ b/pkg/pb/bbgo.proto @@ -4,253 +4,258 @@ package pb; option go_package = "../pb"; -service BBGO { - // should support streaming - rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {} - rpc SubscribeUserData(Empty) returns (stream SubscribeResponse) {} +service MarketDataService { + rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {} + rpc QueryKLines(QueryKLinesRequest) returns (QueryKLinesResponse) {} +} - // request-response - rpc SubmitOrder(SubmitOrderRequest) returns (SubmitOrderResponse) {} - rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {} - rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {} - rpc QueryOrders(QueryOrdersRequest) returns (QueryOrdersResponse) {} - rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {} - rpc QueryKLines(QueryKLinesRequest) returns (QueryKLinesResponse) {} +service UserDataService { + // should support streaming + rpc SubscribeUserData(Empty) returns (stream SubscribeResponse) {} +} + +service TradingService { + // request-response + rpc SubmitOrder(SubmitOrderRequest) returns (SubmitOrderResponse) {} + rpc CancelOrder(CancelOrderRequest) returns (CancelOrderResponse) {} + rpc QueryOrder(QueryOrderRequest) returns (QueryOrderResponse) {} + rpc QueryOrders(QueryOrdersRequest) returns (QueryOrdersResponse) {} + rpc QueryTrades(QueryTradesRequest) returns (QueryTradesResponse) {} } enum Event { - ERROR = 0; - SUBSCRIBED = 1; - UNSUBSCRIBED = 2; - SNAPSHOT = 3; - UPDATE = 4; - AUTHENTICATED = 5; - ORDER_SNAPSHOT = 6; - ORDER_UPDATE = 7; - TRADE_SNAPSHOT = 8; - TRADE_UPDATE = 9; - ACCOUNT_SNAPSHOT = 10; - ACCOUNT_UPDATE = 11; + ERROR = 0; + SUBSCRIBED = 1; + UNSUBSCRIBED = 2; + SNAPSHOT = 3; + UPDATE = 4; + AUTHENTICATED = 5; + ORDER_SNAPSHOT = 6; + ORDER_UPDATE = 7; + TRADE_SNAPSHOT = 8; + TRADE_UPDATE = 9; + ACCOUNT_SNAPSHOT = 10; + ACCOUNT_UPDATE = 11; } enum Channel { - BOOK = 0; - TRADE = 1; - TICKER = 2; - USER = 3; + BOOK = 0; + TRADE = 1; + TICKER = 2; + USER = 3; } enum Side { - BUY = 0; - SELL = 1; + BUY = 0; + SELL = 1; } enum OrderType { - MARKET = 0; - LIMIT = 1; - STOP_MARKET = 2; - STOP_LIMIT = 3; - POST_ONLY = 4; - IOC_LIMIT = 5; + MARKET = 0; + LIMIT = 1; + STOP_MARKET = 2; + STOP_LIMIT = 3; + POST_ONLY = 4; + IOC_LIMIT = 5; } message Empty {} message Error { - int64 error_code = 1; - string error_message = 2; + int64 error_code = 1; + string error_message = 2; } message SubscribeRequest { - repeated Subscription subscriptions = 1; + repeated Subscription subscriptions = 1; } message Subscription { - string exchange = 1; - Channel channel = 2; // book, trade, ticker - string symbol = 3; - int64 depth = 4; + string exchange = 1; + Channel channel = 2; // book, trade, ticker + string symbol = 3; + int64 depth = 4; } message SubscribeResponse { - string exchange = 1; - string symbol = 2; - Channel channel = 3; // book, trade, ticker, user - Event event = 4; // snapshot, update, order_snapshot, ... - Depth depth = 5; - repeated Trade trades = 6; - Ticker ticker = 7; - repeated Order orders = 8; - repeated Balance balances = 9; - int64 subscribed_at = 10; - Error error = 11; + string exchange = 1; + string symbol = 2; + Channel channel = 3; // book, trade, ticker, user + Event event = 4; // snapshot, update, order_snapshot, ... + Depth depth = 5; + repeated Trade trades = 6; + Ticker ticker = 7; + repeated Order orders = 8; + repeated Balance balances = 9; + int64 subscribed_at = 10; + Error error = 11; } message Depth { - string exchange = 1; - string symbol = 2; - repeated PriceVolume asks = 3; - repeated PriceVolume bids = 4; + string exchange = 1; + string symbol = 2; + repeated PriceVolume asks = 3; + repeated PriceVolume bids = 4; } message PriceVolume { - int64 price = 1; - int64 volume = 2; + int64 price = 1; + int64 volume = 2; } // https://maicoin.github.io/max-websocket-docs/#/private_channels?id=trade-response // https://maicoin.github.io/max-websocket-docs/#/public_trade?id=success-response message Trade { - string exchange = 1; - string symbol = 2; - string id = 3; - double price = 4; - double volume = 5; - int64 created_at = 6; - Side side = 7; - double fee = 8; - string fee_currency = 9; - bool maker = 10; - string trend = 11; + string exchange = 1; + string symbol = 2; + string id = 3; + double price = 4; + double volume = 5; + int64 created_at = 6; + Side side = 7; + double fee = 8; + string fee_currency = 9; + bool maker = 10; + string trend = 11; } // https://maicoin.github.io/max-websocket-docs/#/public_ticker?id=success-response message Ticker { - string exchange = 1; - string symbol = 2; - double open = 3; - double high = 4; - double low = 5; - double close = 6; - double volume = 7; + string exchange = 1; + string symbol = 2; + double open = 3; + double high = 4; + double low = 5; + double close = 6; + double volume = 7; } // https://maicoin.github.io/max-websocket-docs/#/private_channels?id=snapshot message Order { - string exchange = 1; - string symbol = 2; - string id = 3; - Side side = 4; - OrderType order_type = 5; - double price = 6; - double stop_price = 7; - double avg_price = 8; - string status = 9; - int64 created_at = 10; - double quantity = 11; - double executed_volume = 12; - int64 trades_count = 13; - string client_order_id = 14; - int64 group_id = 15; + string exchange = 1; + string symbol = 2; + string id = 3; + Side side = 4; + OrderType order_type = 5; + double price = 6; + double stop_price = 7; + double avg_price = 8; + string status = 9; + int64 created_at = 10; + double quantity = 11; + double executed_volume = 12; + int64 trades_count = 13; + string client_order_id = 14; + int64 group_id = 15; } message SubmitOrder { - string exchange = 1; - string symbol = 2; - Side side = 3; - double quantity = 4; - double price = 5; - double stop_price = 6; - OrderType order_type = 7; - string client_order_id = 8; - int64 group_id = 9; + string exchange = 1; + string symbol = 2; + Side side = 3; + double quantity = 4; + double price = 5; + double stop_price = 6; + OrderType order_type = 7; + string client_order_id = 8; + int64 group_id = 9; } // https://maicoin.github.io/max-websocket-docs/#/private_channels?id=account-response message Balance { - string exchange = 1; - string currency = 2; - double available = 3; - double locked = 4; + string exchange = 1; + string currency = 2; + double available = 3; + double locked = 4; } message SubmitOrderRequest { - SubmitOrder submit_order = 1; + SubmitOrder submit_order = 1; } message SubmitOrderResponse { - Order order = 1; - Error error = 2; + Order order = 1; + Error error = 2; } message CancelOrderRequest { - string exchange = 1; - string id = 2; - string client_order_id = 3; + string exchange = 1; + string id = 2; + string client_order_id = 3; } message CancelOrderResponse { - Order order = 1; - Error error = 2; + Order order = 1; + Error error = 2; } message QueryOrderRequest { - string exchange = 1; - string id = 2; - string client_order_id = 3; + string exchange = 1; + string id = 2; + string client_order_id = 3; } message QueryOrderResponse { - Order order = 1; - Error error = 2; + Order order = 1; + Error error = 2; } message QueryOrdersRequest { - string exchange = 1; - string symbol = 2; - repeated string state = 3; - string order_by = 4; - int64 group_id = 5; - bool pagination = 6; - int64 page = 7; - int64 limit = 8; - int64 offset = 9; + string exchange = 1; + string symbol = 2; + repeated string state = 3; + string order_by = 4; + int64 group_id = 5; + bool pagination = 6; + int64 page = 7; + int64 limit = 8; + int64 offset = 9; } message QueryOrdersResponse { - repeated Order orders = 1; - Error error = 2; + repeated Order orders = 1; + Error error = 2; } message QueryTradesRequest { - string exchange = 1; - string symbol = 2; - int64 timestamp = 3; - int64 from = 4; - int64 to = 5; - string order_by = 6; - bool pagination = 7; - int64 page = 8; - int64 limit = 9; - int64 offset = 10; + string exchange = 1; + string symbol = 2; + int64 timestamp = 3; + int64 from = 4; + int64 to = 5; + string order_by = 6; + bool pagination = 7; + int64 page = 8; + int64 limit = 9; + int64 offset = 10; } message QueryTradesResponse { - repeated Trade trades = 1; - Error error = 2; + repeated Trade trades = 1; + Error error = 2; } message QueryKLinesRequest { - string exchange = 1; - string symbol = 2; - int64 limit = 3; - int64 interval = 4; // time period of K line in minute - int64 timestamp = 5; + string exchange = 1; + string symbol = 2; + int64 limit = 3; + int64 interval = 4; // time period of K line in minute + int64 timestamp = 5; } message QueryKLinesResponse { - repeated KLine klines = 1; - Error error = 2; + repeated KLine klines = 1; + Error error = 2; } message KLine { - string exchange = 1; - string symbol = 2; - int64 timestamp = 3; - double open = 4; - double high = 5; - double low = 6; - double close = 7; - double volume = 8; - double quote_volume = 9; + string exchange = 1; + string symbol = 2; + int64 timestamp = 3; + double open = 4; + double high = 5; + double low = 6; + double close = 7; + double volume = 8; + double quote_volume = 9; }