From cf56978f5427f74aaae547bfeca7d4344e7dfd7c Mon Sep 17 00:00:00 2001 From: wurui Date: Sat, 14 Oct 2023 16:29:14 +0800 Subject: [PATCH 01/12] chore(dep): bump to deps (#652) --- example/1-pipeline/go.mod | 8 +++---- example/1-pipeline/go.sum | 22 +++++++++--------- example/2-iopipe/go.mod | 8 +++---- example/2-iopipe/go.sum | 22 +++++++++--------- example/9-cli/source/go.mod | 8 +++---- example/9-cli/source/go.sum | 22 +++++++++--------- go.mod | 22 ++++++++++-------- go.sum | 45 ++++++++++++++++++++++--------------- 8 files changed, 85 insertions(+), 72 deletions(-) diff --git a/example/1-pipeline/go.mod b/example/1-pipeline/go.mod index 29537c6de..9fa213196 100644 --- a/example/1-pipeline/go.mod +++ b/example/1-pipeline/go.mod @@ -19,7 +19,7 @@ require ( github.com/onsi/ginkgo/v2 v2.12.1 // indirect github.com/quic-go/qtls-go1-20 v0.3.4 // indirect github.com/quic-go/quic-go v0.39.0 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.0 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/yomorun/y3 v1.0.5 // indirect go.opentelemetry.io/otel v1.19.0 // indirect @@ -33,12 +33,12 @@ require ( golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.13.0 // indirect - golang.org/x/net v0.16.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.14.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect google.golang.org/grpc v1.58.2 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/example/1-pipeline/go.sum b/example/1-pipeline/go.sum index 4428d5819..c9c8e0cef 100644 --- a/example/1-pipeline/go.sum +++ b/example/1-pipeline/go.sum @@ -3,8 +3,8 @@ github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5 github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -30,8 +30,8 @@ github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjt github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.39.0 h1:AgP40iThFMY0bj8jGxROhw3S0FMGa8ryqsmi9tBH3So= @@ -41,8 +41,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= +github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yomorun/y3 v1.0.5 h1:1qoZrDX+47hgU2pVJgoCEpeeXEOqml/do5oHjF9Wef4= @@ -69,8 +69,8 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjs golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= @@ -78,11 +78,11 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/example/2-iopipe/go.mod b/example/2-iopipe/go.mod index 7591999e6..dc7770a95 100644 --- a/example/2-iopipe/go.mod +++ b/example/2-iopipe/go.mod @@ -19,7 +19,7 @@ require ( github.com/onsi/ginkgo/v2 v2.12.1 // indirect github.com/quic-go/qtls-go1-20 v0.3.4 // indirect github.com/quic-go/quic-go v0.39.0 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.0 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/yomorun/y3 v1.0.5 // indirect go.opentelemetry.io/otel v1.19.0 // indirect @@ -33,12 +33,12 @@ require ( golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.13.0 // indirect - golang.org/x/net v0.16.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.14.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect google.golang.org/grpc v1.58.2 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/example/2-iopipe/go.sum b/example/2-iopipe/go.sum index 4428d5819..c9c8e0cef 100644 --- a/example/2-iopipe/go.sum +++ b/example/2-iopipe/go.sum @@ -3,8 +3,8 @@ github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5 github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -30,8 +30,8 @@ github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjt github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.39.0 h1:AgP40iThFMY0bj8jGxROhw3S0FMGa8ryqsmi9tBH3So= @@ -41,8 +41,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= +github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yomorun/y3 v1.0.5 h1:1qoZrDX+47hgU2pVJgoCEpeeXEOqml/do5oHjF9Wef4= @@ -69,8 +69,8 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjs golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= @@ -78,11 +78,11 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/example/9-cli/source/go.mod b/example/9-cli/source/go.mod index b185777dc..be452d1e1 100644 --- a/example/9-cli/source/go.mod +++ b/example/9-cli/source/go.mod @@ -19,7 +19,7 @@ require ( github.com/onsi/ginkgo/v2 v2.12.1 // indirect github.com/quic-go/qtls-go1-20 v0.3.4 // indirect github.com/quic-go/quic-go v0.39.0 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/msgpack/v5 v5.4.0 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/yomorun/y3 v1.0.5 // indirect go.opentelemetry.io/otel v1.19.0 // indirect @@ -33,12 +33,12 @@ require ( golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.13.0 // indirect - golang.org/x/net v0.16.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.14.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect google.golang.org/grpc v1.58.2 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect diff --git a/example/9-cli/source/go.sum b/example/9-cli/source/go.sum index 4428d5819..c9c8e0cef 100644 --- a/example/9-cli/source/go.sum +++ b/example/9-cli/source/go.sum @@ -3,8 +3,8 @@ github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5 github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -30,8 +30,8 @@ github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjt github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.39.0 h1:AgP40iThFMY0bj8jGxROhw3S0FMGa8ryqsmi9tBH3So= @@ -41,8 +41,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= +github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yomorun/y3 v1.0.5 h1:1qoZrDX+47hgU2pVJgoCEpeeXEOqml/do5oHjF9Wef4= @@ -69,8 +69,8 @@ golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjs golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY= golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= @@ -78,11 +78,11 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/go.mod b/go.mod index 59438e624..58c5c5e19 100644 --- a/go.mod +++ b/go.mod @@ -15,10 +15,10 @@ require ( github.com/second-state/WasmEdge-go v0.13.4 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.16.0 + github.com/spf13/viper v1.17.0 github.com/stretchr/testify v1.8.4 github.com/tetratelabs/wazero v1.5.0 - github.com/vmihailenco/msgpack/v5 v5.3.5 + github.com/vmihailenco/msgpack/v5 v5.4.0 github.com/yomorun/y3 v1.0.5 go.opentelemetry.io/otel v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 @@ -33,7 +33,7 @@ require ( ) require ( - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-logr/logr v1.2.4 // indirect @@ -50,26 +50,30 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/onsi/ginkgo/v2 v2.12.1 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/quic-go/qtls-go1-20 v0.3.4 // indirect - github.com/spf13/afero v1.9.5 // indirect + github.com/sagikazarmark/locafero v0.3.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.10.0 // indirect github.com/spf13/cast v1.5.1 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/stretchr/objx v0.5.1 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/teivah/onecontext v1.3.0 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect go.opentelemetry.io/otel/metric v1.19.0 // indirect go.opentelemetry.io/proto/otlp v1.0.0 // indirect + go.uber.org/atomic v1.9.0 // indirect go.uber.org/goleak v1.1.11 // indirect go.uber.org/mock v0.3.0 // indirect + go.uber.org/multierr v1.9.0 // indirect golang.org/x/crypto v0.14.0 // indirect - golang.org/x/net v0.16.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect google.golang.org/grpc v1.58.2 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index afce1a6de..0eb6a6981 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,9 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= @@ -185,8 +186,9 @@ github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6 github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= @@ -197,26 +199,29 @@ github.com/reactivex/rxgo/v2 v2.5.0/go.mod h1:bs4fVZxcb5ZckLIOeIeVH942yunJLWDABW github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9cJvm4SvQ= +github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/second-state/WasmEdge-go v0.13.4 h1:NHfJC+aayUW93ydAzlcX7Jx1WDRpI24KvY5SAbeTyvY= github.com/second-state/WasmEdge-go v0.13.4/go.mod h1:HyBf9hVj1sRAjklsjc1Yvs9b5RcmthPG9z99dY78TKg= -github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= -github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= +github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= -github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= +github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= +github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0= github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -234,8 +239,8 @@ github.com/teivah/onecontext v1.3.0 h1:tbikMhAlo6VhAuEGCvhc8HlTnpX4xTNPTOseWuhO1 github.com/teivah/onecontext v1.3.0/go.mod h1:hoW1nmdPVK/0jrvGtcx8sCKYs2PiS4z0zzfdeuEVyb0= github.com/tetratelabs/wazero v1.5.0 h1:Yz3fZHivfDiZFUXnWMPUoiW7s8tC1sjdBtlJn08qYa0= github.com/tetratelabs/wazero v1.5.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= -github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= -github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= +github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yomorun/y3 v1.0.5 h1:1qoZrDX+47hgU2pVJgoCEpeeXEOqml/do5oHjF9Wef4= @@ -265,11 +270,15 @@ go.opentelemetry.io/otel/trace v1.19.0 h1:DFVQmlVbfVeOuBRrwdtaehRrWiL1JoVs9CPIQ1 go.opentelemetry.io/otel/trace v1.19.0/go.mod h1:mfaSyvGyEJEI0nyV2I4qhNQnbBOUUmYZpYojqMnX2vo= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= +go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -350,8 +359,8 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= 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= @@ -548,11 +557,11 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= -google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= +google.golang.org/genproto v0.0.0-20230913181813-007df8e322eb h1:XFBgcDwm7irdHTbz4Zk2h7Mh+eis4nfJEFQFYzJzuIA= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= 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= From 82e17ff4e230cd57212dd5e2719e8a6374c5c7fe Mon Sep 17 00:00:00 2001 From: wurui Date: Fri, 20 Oct 2023 23:33:43 +0800 Subject: [PATCH 02/12] feat(log): better log outputs when dispatching to downstreams (#644) --- core/client.go | 72 +++++++++++++++++++----------------------- core/client_test.go | 48 +++++++++++++++------------- core/metadata.go | 15 --------- core/metadata_test.go | 27 ---------------- core/server.go | 24 ++++++++------ core/server_options.go | 3 +- sfn.go | 49 ++++++++++++++++++---------- source.go | 21 ++++++++---- zipper.go | 27 ++++++++++++++-- 9 files changed, 143 insertions(+), 143 deletions(-) diff --git a/core/client.go b/core/client.go index 4a673f78a..8d18cef3f 100644 --- a/core/client.go +++ b/core/client.go @@ -21,6 +21,7 @@ import ( // Client is the abstraction of a YoMo-Client. a YoMo-Client can be // Source, Upstream Zipper or StreamFunction. type Client struct { + zipperAddr string name string // name of the client clientID string // id of the client clientType ClientType // type of the client @@ -28,7 +29,7 @@ type Client struct { receiver func(*frame.BackflowFrame) // function to invoke when data is processed errorfn func(error) // function to invoke when error occured opts *clientOptions - logger *slog.Logger + Logger *slog.Logger tracerProvider oteltrace.TracerProvider // ctx and ctxCancel manage the lifecycle of client. @@ -39,7 +40,7 @@ type Client struct { } // NewClient creates a new YoMo-Client. -func NewClient(appName string, clientType ClientType, opts ...ClientOption) *Client { +func NewClient(appName, zipperAddr string, clientType ClientType, opts ...ClientOption) *Client { option := defaultClientOption() for _, o := range opts { @@ -47,22 +48,19 @@ func NewClient(appName string, clientType ClientType, opts ...ClientOption) *Cli } clientID := id.New() - logger := option.logger.With("component", clientType.String(), "client_id", clientID, "client_name", appName) - - if option.credential != nil { - logger.Info("use credential", "credential_name", option.credential.Name()) - } + logger := option.logger ctx, ctxCancel := context.WithCancelCause(context.Background()) return &Client{ + zipperAddr: zipperAddr, name: appName, clientID: clientID, processor: func(df *frame.DataFrame) { logger.Warn("the processor has not been set") }, receiver: func(bf *frame.BackflowFrame) { logger.Warn("the receiver has not been set") }, clientType: clientType, opts: option, - logger: logger, + Logger: logger, tracerProvider: option.tracerProvider, errorfn: func(err error) { logger.Error("client err", "err", err) }, writeFrameChan: make(chan frame.Frame), @@ -85,8 +83,8 @@ func newConnectResult(conn quic.Connection, fs *FrameStream, err error) *connect } } -func (c *Client) connect(ctx context.Context, addr string) *connectResult { - conn, err := quic.DialAddr(ctx, addr, c.opts.tlsConfig, c.opts.quicConfig) +func (c *Client) connect(ctx context.Context) *connectResult { + conn, err := quic.DialAddr(ctx, c.zipperAddr, c.opts.tlsConfig, c.opts.quicConfig) if err != nil { return newConnectResult(conn, nil, err) } @@ -98,6 +96,10 @@ func (c *Client) connect(ctx context.Context, addr string) *connectResult { fs := NewFrameStream(stream, y3codec.Codec(), y3codec.PacketReadWriter()) + if credential := c.opts.credential; credential != nil { + c.Logger.Info("use credential", "credential_name", credential.Name()) + } + hf := &frame.HandshakeFrame{ Name: c.name, ID: c.clientID, @@ -130,7 +132,7 @@ func (c *Client) connect(ctx context.Context, addr string) *connectResult { } } -func (c *Client) runBackground(ctx context.Context, addr string, conn quic.Connection, fs *FrameStream) { +func (c *Client) runBackground(ctx context.Context, conn quic.Connection, fs *FrameStream) { reconnection := make(chan struct{}) go c.handleReadFrames(fs, reconnection) @@ -149,12 +151,12 @@ func (c *Client) runBackground(ctx context.Context, addr string, conn quic.Conne } case <-reconnection: reconnect: - cr := c.connect(ctx, addr) + cr := c.connect(ctx) if err := cr.err; err != nil { if errors.As(err, new(ErrAuthenticateFailed)) { return } - c.logger.Error("reconnect to zipper error", "err", cr.err) + c.Logger.Error("reconnect to zipper error", "err", cr.err) time.Sleep(time.Second) goto reconnect } @@ -165,27 +167,21 @@ func (c *Client) runBackground(ctx context.Context, addr string, conn quic.Conne } // Connect connect client to server. -func (c *Client) Connect(ctx context.Context, addr string) error { - if c.clientType == ClientTypeStreamFunction && len(c.opts.observeDataTags) == 0 { - return errors.New("yomo: streamFunction cannot observe data because the required tag has not been set") - } - - c.logger = c.logger.With("zipper_addr", addr) - +func (c *Client) Connect(ctx context.Context) error { connect: - result := c.connect(ctx, addr) + result := c.connect(ctx) if result.err != nil { if c.opts.connectUntilSucceed { - c.logger.Error("failed to connect to zipper, trying to reconnect", "err", result.err) + c.Logger.Error("failed to connect to zipper, trying to reconnect", "err", result.err) time.Sleep(time.Second) goto connect } - c.logger.Error("can not connect to zipper", "err", result.err) + c.Logger.Error("can not connect to zipper", "err", result.err) return result.err } - c.logger.Info("connected to zipper") + c.Logger.Info("connected to zipper") - go c.runBackground(ctx, addr, result.conn, result.fs) + go c.runBackground(ctx, result.conn, result.fs) return nil } @@ -217,7 +213,7 @@ func (c *Client) nonBlockWriteFrame(f frame.Frame) error { return nil default: err := errors.New("yomo: client has lost connection") - c.logger.Debug("failed to write frame", "frame_type", f.Type().String(), "error", err) + c.Logger.Debug("failed to write frame", "frame_type", f.Type().String(), "error", err) return err } } @@ -275,7 +271,7 @@ func (c *Client) handleReadFrames(fs *FrameStream, reconnection chan struct{}) { buf = buf[:runtime.Stack(buf, false)] perr := fmt.Errorf("%v", e) - c.logger.Error("stream panic", "err", perr) + c.Logger.Error("stream panic", "err", perr) c.errorfn(fmt.Errorf("yomo: stream panic: %v\n%s", perr, buf)) } }() @@ -287,14 +283,14 @@ func (c *Client) handleReadFrames(fs *FrameStream, reconnection chan struct{}) { func (c *Client) handleFrame(f frame.Frame) { switch ff := f.(type) { case *frame.RejectedFrame: - c.logger.Error("rejected error", "err", ff.Message) + c.Logger.Error("rejected error", "err", ff.Message) _ = c.Close() case *frame.DataFrame: c.processor(ff) case *frame.BackflowFrame: c.receiver(ff) default: - c.logger.Warn("received unexpected frame", "frame_type", f.Type().String()) + c.Logger.Warn("received unexpected frame", "frame_type", f.Type().String()) } } @@ -313,15 +309,10 @@ func (c *Client) SetObserveDataTags(tag ...frame.Tag) { c.opts.observeDataTags = tag } -// Logger get client's logger instance, you can customize this using `yomo.WithLogger` -func (c *Client) Logger() *slog.Logger { - return c.logger -} - // SetErrorHandler set error handler func (c *Client) SetErrorHandler(fn func(err error)) { c.errorfn = fn - c.logger.Debug("the error handler has been set") + c.Logger.Debug("the error handler has been set") } // ClientID returns the ID of client. @@ -330,13 +321,14 @@ func (c *Client) ClientID() string { return c.clientID } // Name returns the name of client. func (c *Client) Name() string { return c.name } -// FrameWriterConnection represents a frame writer that can connect to an addr. -type FrameWriterConnection interface { +// Downstream represents a frame writer that can connect to an addr. +type Downstream interface { frame.Writer - ClientID() string - Name() string + ID() string + LocalName() string + RemoteName() string Close() error - Connect(context.Context, string) error + Connect(context.Context) error } // TracerProvider returns the tracer provider of client. diff --git a/core/client_test.go b/core/client_test.go index 7eee0c4ee..22b660cdf 100644 --- a/core/client_test.go +++ b/core/client_test.go @@ -16,7 +16,6 @@ import ( "github.com/yomorun/yomo/core/router" "github.com/yomorun/yomo/core/ylog" "github.com/yomorun/yomo/pkg/frame-codec/y3codec" - "github.com/yomorun/yomo/pkg/id" ) const testaddr = "127.0.0.1:19999" @@ -29,8 +28,8 @@ var discardingLogger = ylog.NewFromConfig(ylog.Config{Output: "/dev/null", Error func TestClientDialNothing(t *testing.T) { ctx := context.Background() - client := NewClient("source", ClientTypeSource, WithLogger(discardingLogger)) - err := client.Connect(ctx, testaddr) + client := NewClient("source", testaddr, ClientTypeSource, WithLogger(discardingLogger)) + err := client.Connect(ctx) qerr := net.ErrClosed assert.ErrorAs(t, err, &qerr, "dial must timeout") @@ -60,22 +59,23 @@ func TestFrameRoundTrip(t *testing.T) { server.SetBeforeHandlers(ht.beforeHandler) server.SetAfterHandlers(ht.afterHandler) - recorder := newFrameWriterRecorder("mockClient") - server.AddDownstreamServer("mockAddr", recorder) + recorder := newFrameWriterRecorder("mockID", "mockClientLocal", "mockClientRemote") + server.AddDownstreamServer(recorder) - assert.Equal(t, server.Downstreams()["mockAddr"], recorder.ClientID()) + assert.Equal(t, server.Downstreams()["mockID"], recorder.ID()) go func() { err := server.ListenAndServe(ctx, testaddr) fmt.Println(err) }() - illegalTokenSource := NewClient("source", ClientTypeSource, WithCredential("token:error-token"), WithLogger(discardingLogger)) - err := illegalTokenSource.Connect(ctx, testaddr) + illegalTokenSource := NewClient("source", testaddr, ClientTypeSource, WithCredential("token:error-token"), WithLogger(discardingLogger)) + err := illegalTokenSource.Connect(ctx) assert.Equal(t, "authentication failed: client credential name is token", err.Error()) source := NewClient( "source", + testaddr, ClientTypeSource, WithCredential("token:auth-token"), WithClientQuicConfig(DefalutQuicConfig), @@ -90,10 +90,10 @@ func TestFrameRoundTrip(t *testing.T) { assert.Equal(t, string(backflow), string(bf.Carriage)) }) - err = source.Connect(ctx, testaddr) + err = source.Connect(ctx) assert.NoError(t, err, "source connect must be success") - closeEarlySfn := createTestStreamFunction("close-early-sfn", observedTag) - closeEarlySfn.Connect(ctx, testaddr) + closeEarlySfn := createTestStreamFunction("close-early-sfn", testaddr, observedTag) + closeEarlySfn.Connect(ctx) assert.Equal(t, nil, err) // test close early. @@ -104,7 +104,7 @@ func TestFrameRoundTrip(t *testing.T) { assert.True(t, exited, "close-early-sfn should exited") // sfn to zipper. - sfn := createTestStreamFunction("sfn-1", observedTag) + sfn := createTestStreamFunction("sfn-1", testaddr, observedTag) sfn.SetDataFrameObserver(func(bf *frame.DataFrame) { assert.Equal(t, string(payload), string(bf.Payload)) @@ -123,7 +123,7 @@ func TestFrameRoundTrip(t *testing.T) { } }) - err = sfn.Connect(ctx, testaddr) + err = sfn.Connect(ctx) assert.NoError(t, err, "sfn connect should replace the old sfn stream") exited = checkClientExited(sfn, time.Second) @@ -211,9 +211,10 @@ func (a *hookTester) afterHandler(ctx *Context) error { return nil } -func createTestStreamFunction(name string, observedTag frame.Tag) *Client { +func createTestStreamFunction(name string, zipperAddr string, observedTag frame.Tag) *Client { sfn := NewClient( name, + zipperAddr, ClientTypeStreamFunction, WithCredential("token:auth-token"), WithLogger(discardingLogger), @@ -226,27 +227,30 @@ func createTestStreamFunction(name string, observedTag frame.Tag) *Client { // frameWriterRecorder frames be writen. type frameWriterRecorder struct { id string - name string + localName string + remoteName string codec frame.Codec packetReader frame.PacketReadWriter mu sync.Mutex buf *bytes.Buffer } -func newFrameWriterRecorder(name string) *frameWriterRecorder { +func newFrameWriterRecorder(id, localName, remoteName string) *frameWriterRecorder { return &frameWriterRecorder{ - id: id.New(), - name: name, + id: id, + localName: localName, + remoteName: remoteName, codec: y3codec.Codec(), packetReader: y3codec.PacketReadWriter(), buf: new(bytes.Buffer), } } -func (w *frameWriterRecorder) ClientID() string { return w.id } -func (w *frameWriterRecorder) Name() string { return w.name } -func (w *frameWriterRecorder) Close() error { return nil } -func (w *frameWriterRecorder) Connect(_ context.Context, _ string) error { return nil } +func (w *frameWriterRecorder) ID() string { return w.id } +func (w *frameWriterRecorder) LocalName() string { return w.localName } +func (w *frameWriterRecorder) RemoteName() string { return w.remoteName } +func (w *frameWriterRecorder) Close() error { return nil } +func (w *frameWriterRecorder) Connect(_ context.Context) error { return nil } func (w *frameWriterRecorder) WriteFrame(f frame.Frame) error { w.mu.Lock() diff --git a/core/metadata.go b/core/metadata.go index a60b6a958..ce99886f0 100644 --- a/core/metadata.go +++ b/core/metadata.go @@ -2,7 +2,6 @@ package core import ( "github.com/yomorun/yomo/core/metadata" - "golang.org/x/exp/slog" ) const ( @@ -68,17 +67,3 @@ func SetTracedToMetadata(m metadata.M, traced bool) { } m.Set(MetaTraced, tracedString) } - -// MetadataSlogAttr returns slog.Attr from metadata. -func MetadataSlogAttr(md metadata.M) slog.Attr { - kvStrings := make([]any, len(md)*2) - i := 0 - for k, v := range md { - kvStrings[i] = k - i++ - kvStrings[i] = v - i++ - } - - return slog.Group("metadata", kvStrings...) -} diff --git a/core/metadata_test.go b/core/metadata_test.go index c39f93dcb..9037e4891 100644 --- a/core/metadata_test.go +++ b/core/metadata_test.go @@ -1,12 +1,9 @@ package core import ( - "bytes" "testing" "github.com/stretchr/testify/assert" - "github.com/yomorun/yomo/core/metadata" - "golang.org/x/exp/slog" ) func TestMetadata(t *testing.T) { @@ -26,27 +23,3 @@ func TestMetadata(t *testing.T) { SetTracedToMetadata(md, false) assert.Equal(t, false, GetTracedFromMetadata(md)) } - -func TestMetadataSlogAttr(t *testing.T) { - md := metadata.New(map[string]string{ - "aaaa": "bbbb", - }) - - buf := bytes.NewBuffer(nil) - - logger := slog.New(slog.NewTextHandler(buf, &slog.HandlerOptions{ - AddSource: false, - Level: slog.LevelDebug, - // display time attr. - ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr { - if a.Key == "time" { - return slog.Attr{} - } - return a - }, - })) - - logger.Debug("test metadata", MetadataSlogAttr(md)) - - assert.Equal(t, "level=DEBUG msg=\"test metadata\" metadata.aaaa=bbbb\n", buf.String()) -} diff --git a/core/server.go b/core/server.go index 9b28b57ba..d34b1f0a0 100644 --- a/core/server.go +++ b/core/server.go @@ -45,7 +45,7 @@ type Server struct { codec frame.Codec packetReadWriter frame.PacketReadWriter counterOfDataFrame int64 - downstreams map[string]FrameWriterConnection + downstreams map[string]Downstream mu sync.Mutex opts *serverOptions startHandlers []FrameHandler @@ -73,7 +73,7 @@ func NewServer(name string, opts ...ServerOption) *Server { ctx: ctx, ctxCancel: ctxCancel, name: name, - downstreams: make(map[string]FrameWriterConnection), + downstreams: make(map[string]Downstream), logger: logger, tracerProvider: options.tracerProvider, codec: y3codec.Codec(), @@ -96,8 +96,8 @@ func (s *Server) ListenAndServe(ctx context.Context, addr string) error { } // connect to all downstreams. - for addr, client := range s.downstreams { - go client.Connect(ctx, addr) + for _, client := range s.downstreams { + go client.Connect(ctx) } return s.Serve(ctx, conn) @@ -149,7 +149,7 @@ func (s *Server) handleConnection(qconn quic.Connection, fs *FrameStream, logger } logger = logger.With("conn_id", conn.ID(), "conn_name", conn.Name()) - logger.Info("client connected", "remote_addr", qconn.RemoteAddr().String(), "client_type", conn.ClientType().String()) + logger.Info("new client connected", "remote_addr", qconn.RemoteAddr().String(), "client_type", conn.ClientType().String()) c := newContext(conn, route, logger) @@ -300,7 +300,7 @@ func (s *Server) Close() error { return nil } -func closeServer(downstreams map[string]FrameWriterConnection, connector *Connector, listener *quic.Listener, router router.Router) error { +func closeServer(downstreams map[string]Downstream, connector *Connector, listener *quic.Listener, router router.Router) error { for _, ds := range downstreams { ds.Close() } @@ -482,7 +482,7 @@ func (s *Server) Downstreams() map[string]string { snapshotOfDownstream := make(map[string]string, len(s.downstreams)) for addr, client := range s.downstreams { - snapshotOfDownstream[addr] = client.ClientID() + snapshotOfDownstream[addr] = client.ID() } return snapshotOfDownstream } @@ -497,9 +497,9 @@ func (s *Server) ConfigRouter(router router.Router) { // AddDownstreamServer add a downstream server to this server. all the DataFrames will be // dispatch to all the downstreams. -func (s *Server) AddDownstreamServer(addr string, c FrameWriterConnection) { +func (s *Server) AddDownstreamServer(c Downstream) { s.mu.Lock() - s.downstreams[addr] = c + s.downstreams[c.ID()] = c s.mu.Unlock() } @@ -524,7 +524,11 @@ func (s *Server) dispatchToDownstreams(c *Context) { dataFrame.Metadata = mdBytes for _, ds := range s.downstreams { - c.Logger.Info("dispatching to downstream", "tid", tid, "sid", sid, "tag", dataFrame.Tag, "data_length", len(dataFrame.Payload), "downstream_id", ds.ClientID()) + c.Logger.Info( + "dispatching to downstream", + "tid", tid, "sid", sid, "tag", dataFrame.Tag, "data_length", len(dataFrame.Payload), + "downstream_id", ds.ID(), "downstream_name", ds.LocalName(), + ) _ = ds.WriteFrame(dataFrame) } } diff --git a/core/server_options.go b/core/server_options.go index 63e570455..18d565f27 100644 --- a/core/server_options.go +++ b/core/server_options.go @@ -27,8 +27,7 @@ var DefalutQuicConfig = &quic.Config{ // ServerOption is the option for server. type ServerOption func(*serverOptions) -// ServerOptions are the options for YoMo server. -// TODO: quic alpn function. +// serverOptions are the options for YoMo server. type serverOptions struct { quicConfig *quic.Config tlsConfig *tls.Config diff --git a/sfn.go b/sfn.go index 26b35e1b8..364ef38b4 100644 --- a/sfn.go +++ b/sfn.go @@ -2,6 +2,7 @@ package yomo import ( "context" + "errors" "github.com/yomorun/yomo/core" "github.com/yomorun/yomo/core/frame" @@ -39,7 +40,16 @@ func NewStreamFunction(name, zipperAddr string, opts ...SfnOption) StreamFunctio for k, v := range opts { clientOpts[k] = core.ClientOption(v) } - client := core.NewClient(name, core.ClientTypeStreamFunction, clientOpts...) + + client := core.NewClient(name, zipperAddr, core.ClientTypeStreamFunction, clientOpts...) + + client.Logger = client.Logger.With( + "component", core.ClientTypeStreamFunction.String(), + "sfn_id", client.ClientID(), + "sfn_name", client.Name(), + "zipper_addr", zipperAddr, + ) + sfn := &streamFunction{ name: name, zipperAddr: zipperAddr, @@ -67,30 +77,35 @@ type streamFunction struct { // SetObserveDataTags set the data tag list that will be observed. // Deprecated: use yomo.WithObserveDataTags instead func (s *streamFunction) SetObserveDataTags(tag ...uint32) { + s.observeDataTags = tag s.client.SetObserveDataTags(tag...) - s.client.Logger().Debug("set sfn observe data tasg", "tags", s.observeDataTags) + s.client.Logger.Debug("set sfn observe data tasg", "tags", s.observeDataTags) } // SetHandler set the handler function, which accept the raw bytes data and return the tag & response. func (s *streamFunction) SetHandler(fn core.AsyncHandler) error { s.fn = fn - s.client.Logger().Debug("set async handler") + s.client.Logger.Debug("set async handler") return nil } func (s *streamFunction) SetPipeHandler(fn core.PipeHandler) error { s.pfn = fn - s.client.Logger().Debug("set pipe handler") + s.client.Logger.Debug("set pipe handler") return nil } // Connect create a connection to the zipper, when data arrvied, the data will be passed to the // handler which setted by SetHandler method. func (s *streamFunction) Connect() error { - s.client.Logger().Debug("sfn connecting to zipper ...") + if len(s.observeDataTags) == 0 { + return errors.New("streamFunction cannot observe data because the required tag has not been set") + } + + s.client.Logger.Debug("sfn connecting to zipper ...") // notify underlying network operations, when data with tag we observed arrived, invoke the func s.client.SetDataFrameObserver(func(data *frame.DataFrame) { - s.client.Logger().Debug("received data frame") + s.client.Logger.Debug("received data frame") s.onDataFrame(data) }) @@ -108,19 +123,19 @@ func (s *streamFunction) Connect() error { for { data := <-s.pOut if data != nil { - s.client.Logger().Debug("pipe fn send", "payload_frame", data) + s.client.Logger.Debug("pipe fn send", "payload_frame", data) md, err := metadata.Decode(data.Metadata) if err != nil { - s.client.Logger().Error("sfn decode metadata error", "err", err) + s.client.Logger.Error("sfn decode metadata error", "err", err) break } - newMd, deferFunc := ExtendTraceMetadata(md, s.client.ClientID(), s.client.Name(), s.client.TracerProvider(), s.client.Logger()) + newMd, deferFunc := ExtendTraceMetadata(md, s.client.ClientID(), s.client.Name(), s.client.TracerProvider(), s.client.Logger) defer deferFunc() newMetadata, err := newMd.Encode() if err != nil { - s.client.Logger().Error("sfn encode metadata error", "err", err) + s.client.Logger.Error("sfn encode metadata error", "err", err) break } data.Metadata = newMetadata @@ -137,7 +152,7 @@ func (s *streamFunction) Connect() error { }() } - err := s.client.Connect(context.Background(), s.zipperAddr) + err := s.client.Connect(context.Background()) return err } @@ -153,7 +168,7 @@ func (s *streamFunction) Close() error { if s.client != nil { if err := s.client.Close(); err != nil { - s.client.Logger().Error("failed to close sfn", "err", err) + s.client.Logger.Error("failed to close sfn", "err", err) return err } } @@ -174,16 +189,16 @@ func (s *streamFunction) onDataFrame(dataFrame *frame.DataFrame) { go func(tp oteltrace.TracerProvider, dataFrame *frame.DataFrame) { md, err := metadata.Decode(dataFrame.Metadata) if err != nil { - s.client.Logger().Error("sfn decode metadata error", "err", err) + s.client.Logger.Error("sfn decode metadata error", "err", err) return } - newMd, deferFunc := ExtendTraceMetadata(md, s.client.ClientID(), s.client.Name(), s.client.TracerProvider(), s.client.Logger()) + newMd, deferFunc := ExtendTraceMetadata(md, s.client.ClientID(), s.client.Name(), s.client.TracerProvider(), s.client.Logger) defer deferFunc() newMetadata, err := newMd.Encode() if err != nil { - s.client.Logger().Error("sfn encode metadata error", "err", err) + s.client.Logger.Error("sfn encode metadata error", "err", err) return } dataFrame.Metadata = newMetadata @@ -193,10 +208,10 @@ func (s *streamFunction) onDataFrame(dataFrame *frame.DataFrame) { }(tp, dataFrame) } else if s.pfn != nil { data := dataFrame.Payload - s.client.Logger().Debug("pipe sfn receive", "data_len", len(data), "data", data) + s.client.Logger.Debug("pipe sfn receive", "data_len", len(data), "data", data) s.pIn <- data } else { - s.client.Logger().Warn("sfn does not have a handler") + s.client.Logger.Warn("sfn does not have a handler") } } diff --git a/source.go b/source.go index 72e8d3b19..61718f807 100644 --- a/source.go +++ b/source.go @@ -43,7 +43,14 @@ func NewSource(name, zipperAddr string, opts ...SourceOption) Source { clientOpts[k] = core.ClientOption(v) } - client := core.NewClient(name, core.ClientTypeSource, clientOpts...) + client := core.NewClient(name, zipperAddr, core.ClientTypeSource, clientOpts...) + + client.Logger = client.Logger.With( + "component", core.ClientTypeSource.String(), + "source_id", client.ClientID(), + "source_name", client.Name(), + "zipper_addr", zipperAddr, + ) return &yomoSource{ name: name, @@ -55,10 +62,10 @@ func NewSource(name, zipperAddr string, opts ...SourceOption) Source { // Close will close the connection to YoMo-Zipper. func (s *yomoSource) Close() error { if err := s.client.Close(); err != nil { - s.client.Logger().Error("failed to close the source", "err", err) + s.client.Logger.Error("failed to close the source", "err", err) return err } - s.client.Logger().Debug("the source is closed") + s.client.Logger.Debug("the source is closed") return nil } @@ -71,13 +78,13 @@ func (s *yomoSource) Connect() error { } }) - err := s.client.Connect(context.Background(), s.zipperAddr) + err := s.client.Connect(context.Background()) return err } // Write writes data with specified tag. func (s *yomoSource) Write(tag uint32, data []byte) error { - md, deferFunc := TraceMetadata(s.client.ClientID(), s.name, s.client.TracerProvider(), s.client.Logger()) + md, deferFunc := TraceMetadata(s.client.ClientID(), s.name, s.client.TracerProvider(), s.client.Logger) defer deferFunc() mdBytes, err := md.Encode() @@ -90,7 +97,7 @@ func (s *yomoSource) Write(tag uint32, data []byte) error { Metadata: mdBytes, Payload: data, } - s.client.Logger().Debug("source write", "tag", tag, "data", data) + s.client.Logger.Debug("source write", "tag", tag, "data", data) return s.client.WriteFrame(f) } @@ -102,7 +109,7 @@ func (s *yomoSource) SetErrorHandler(fn func(err error)) { // [Experimental] SetReceiveHandler set the observe handler function func (s *yomoSource) SetReceiveHandler(fn func(uint32, []byte)) { s.fn = fn - s.client.Logger().Info("receive hander set for the source") + s.client.Logger.Info("receive hander set for the source") } // TraceMetadata generates source trace metadata. diff --git a/zipper.go b/zipper.go index 823fc85d1..3b3cfd3c8 100644 --- a/zipper.go +++ b/zipper.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/yomorun/yomo/core" + "github.com/yomorun/yomo/core/frame" "github.com/yomorun/yomo/core/router" "github.com/yomorun/yomo/pkg/config" "golang.org/x/exp/slog" @@ -65,16 +66,24 @@ func NewZipper(name string, meshConfig map[string]config.Downstream, options ... for downstreamName, meshConf := range meshConfig { addr := fmt.Sprintf("%s:%d", meshConf.Host, meshConf.Port) + dsLogger := server.Logger().With("downstream_name", downstreamName, "downstream_addr", addr) + clientOptions := append( opts.clientOption, core.WithCredential(meshConf.Credential), core.WithNonBlockWrite(), core.WithConnectUntilSucceed(), + core.WithLogger(dsLogger), ) - downstream := core.NewClient(name, core.ClientTypeUpstreamZipper, clientOptions...) - server.Logger().Info("add downstream", "name", downstreamName, "addr", addr, "downstream_id", downstream.ClientID()) - server.AddDownstreamServer(addr, downstream) + downstream := &downstream{ + localName: downstreamName, + client: core.NewClient(name, addr, core.ClientTypeUpstreamZipper, clientOptions...), + } + + server.Logger().Info("add downstream", "downstream_id", downstream.ID(), "downstream_name", downstream.LocalName(), "downstream_addr", addr) + + server.AddDownstreamServer(downstream) } server.ConfigRouter(router.Default()) @@ -96,3 +105,15 @@ func statsToLogger(server *core.Server) { "data_frame_received_num", server.StatsCounter(), ) } + +type downstream struct { + localName string + client *core.Client +} + +func (d *downstream) Close() error { return d.client.Close() } +func (d *downstream) Connect(ctx context.Context) error { return d.client.Connect(ctx) } +func (d *downstream) ID() string { return d.client.ClientID() } +func (d *downstream) LocalName() string { return d.localName } +func (d *downstream) RemoteName() string { return d.client.Name() } +func (d *downstream) WriteFrame(f frame.Frame) error { return d.client.WriteFrame(f) } From d4c8685c8811103be775cb5dfc73d02c18bc6474 Mon Sep 17 00:00:00 2001 From: wurui Date: Fri, 20 Oct 2023 23:36:53 +0800 Subject: [PATCH 03/12] test: fix client unittest (#643) # Description fix unittest bug: The downstream be written twice in unittest case, fix to read the recorder and assert the read result twice. --- core/client_test.go | 45 +++++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/core/client_test.go b/core/client_test.go index 22b660cdf..8cb2acb53 100644 --- a/core/client_test.go +++ b/core/client_test.go @@ -39,8 +39,8 @@ func TestFrameRoundTrip(t *testing.T) { ctx := context.Background() var ( - observedTag = frame.Tag(1) - backflowTag = frame.Tag(2) + observedTag = frame.Tag(0x13) + backflowTag = frame.Tag(0x14) payload = []byte("hello data frame") backflow = []byte("hello backflow frame") ) @@ -129,11 +129,21 @@ func TestFrameRoundTrip(t *testing.T) { exited = checkClientExited(sfn, time.Second) assert.False(t, exited, "sfn stream should not exited") - sfnMetaBytes, _ := NewDefaultMetadata(source.clientID, "tid", "sid", false).Encode() + sfnMd := NewDefaultMetadata(source.clientID, "sfn-tid", "sfn-sid", false) - err = sfn.WriteFrame(&frame.DataFrame{Tag: backflowTag, Metadata: sfnMetaBytes, Payload: backflow}) + sfnMetaBytes, _ := sfnMd.Encode() + + dataFrame := &frame.DataFrame{ + Tag: backflowTag, + Metadata: sfnMetaBytes, + Payload: backflow, + } + + err = sfn.WriteFrame(dataFrame) assert.NoError(t, err) + assertDownstreamDataFrame(t, dataFrame.Tag, sfnMd, dataFrame.Payload, recorder) + stats := server.StatsFunctions() nameList := []string{} for _, name := range stats { @@ -149,7 +159,7 @@ func TestFrameRoundTrip(t *testing.T) { ) sourceMetaBytes, _ := md.Encode() - dataFrame := &frame.DataFrame{ + dataFrame = &frame.DataFrame{ Tag: observedTag, Metadata: sourceMetaBytes, Payload: payload, @@ -158,12 +168,7 @@ func TestFrameRoundTrip(t *testing.T) { err = source.WriteFrame(dataFrame) assert.NoError(t, err, "source write dataFrame must be success") - time.Sleep(2 * time.Second) - - recordTag, recordMD, recordPayload := recorder.dataFrameContent() - assert.True(t, recordTag == dataFrame.Tag || recordTag == backflowTag) - assert.Equal(t, GetSourceIDFromMetadata(recordMD), source.clientID) - assert.True(t, bytes.Equal(recordPayload, dataFrame.Payload) || bytes.Equal(recordPayload, backflow)) + assertDownstreamDataFrame(t, dataFrame.Tag, md, dataFrame.Payload, recorder) assert.NoError(t, source.Close(), "source client.Close() should not return error") assert.NoError(t, sfn.Close(), "sfn client.Close() should not return error") @@ -257,17 +262,29 @@ func (w *frameWriterRecorder) WriteFrame(f frame.Frame) error { defer w.mu.Unlock() b, _ := w.codec.Encode(f) - _, err := w.buf.Write(b) + err := w.packetReader.WritePacket(w.buf, f.Type(), b) return err } -func (w *frameWriterRecorder) dataFrameContent() (frame.Tag, metadata.M, []byte) { +func (w *frameWriterRecorder) ReadFrameContent() (frame.Tag, metadata.M, []byte) { w.mu.Lock() defer w.mu.Unlock() dataFrame := new(frame.DataFrame) - y3codec.Codec().Decode(w.buf.Bytes(), dataFrame) + + _, bytes, _ := w.packetReader.ReadPacket(w.buf) + w.codec.Decode(bytes, dataFrame) md, _ := metadata.Decode(dataFrame.Metadata) return dataFrame.Tag, md, dataFrame.Payload } + +func assertDownstreamDataFrame(t *testing.T, tag uint32, md metadata.M, payload []byte, recorder *frameWriterRecorder) { + // wait for the downstream to finish writing. + time.Sleep(time.Second) + + recordTag, recordMD, recordPayload := recorder.ReadFrameContent() + assert.Equal(t, recordTag, tag) + assert.Equal(t, recordMD, md) + assert.Equal(t, recordPayload, payload) +} From 6071f7de34d327a0b76dd646d2a8a64bb6b7d806 Mon Sep 17 00:00:00 2001 From: wurui Date: Fri, 20 Oct 2023 23:52:03 +0800 Subject: [PATCH 04/12] refactor: logger with tid & improve open tracing in metadata (#651) --- core/client_test.go | 4 +- core/context.go | 3 + core/metadata.go | 154 ++++++++++++++++++++++++++++++++++-------- core/metadata_test.go | 14 +--- core/server.go | 65 ++++-------------- pkg/id/id.go | 8 +-- pkg/id/id_test.go | 22 +++--- sfn.go | 56 ++------------- source.go | 38 +---------- 9 files changed, 168 insertions(+), 196 deletions(-) diff --git a/core/client_test.go b/core/client_test.go index 8cb2acb53..af2a1a8c7 100644 --- a/core/client_test.go +++ b/core/client_test.go @@ -129,7 +129,7 @@ func TestFrameRoundTrip(t *testing.T) { exited = checkClientExited(sfn, time.Second) assert.False(t, exited, "sfn stream should not exited") - sfnMd := NewDefaultMetadata(source.clientID, "sfn-tid", "sfn-sid", false) + sfnMd := NewMetadata(source.clientID, "tid", "trace-id", "span-id", false) sfnMetaBytes, _ := sfnMd.Encode() @@ -152,7 +152,7 @@ func TestFrameRoundTrip(t *testing.T) { assert.ElementsMatch(t, nameList, []string{"source", "sfn-1"}) md := metadata.New( - NewDefaultMetadata(source.clientID, "tid", "sid", false), + NewMetadata(source.clientID, "tid", "trace-id", "span-id", false), metadata.M{ "foo": "bar", }, diff --git a/core/context.go b/core/context.go index 8f8ed1055..9bdb42a4d 100644 --- a/core/context.go +++ b/core/context.go @@ -132,6 +132,9 @@ func (c *Context) WithFrame(f frame.Frame) error { c.Frame = df c.FrameMetadata = fmd + // log with tid + c.Logger = c.BaseLogger.With("tid", GetTIDFromMetadata(fmd)) + return nil } diff --git a/core/metadata.go b/core/metadata.go index ce99886f0..579e71457 100644 --- a/core/metadata.go +++ b/core/metadata.go @@ -2,26 +2,31 @@ package core import ( "github.com/yomorun/yomo/core/metadata" + "github.com/yomorun/yomo/pkg/id" + "github.com/yomorun/yomo/pkg/trace" + oteltrace "go.opentelemetry.io/otel/trace" + "golang.org/x/exp/slog" ) const ( + // the keys for yomo working. MetadataSourceIDKey = "yomo-source-id" MetadataTIDKey = "yomo-tid" - MetadataSIDKey = "yomo-sid" - MetaTraced = "yomo-traced" + + // the keys for tracing. + MetadataTraceIDKey = "yomo-trace-id" + MetadataSpanIDKey = "yomo-span-id" + MetaTracedKey = "yomo-traced" ) -// NewDefaultMetadata returns a default metadata. -func NewDefaultMetadata(sourceID string, tid string, sid string, traced bool) metadata.M { - tracedString := "false" - if traced { - tracedString = "true" - } +// NewMetadata returns metadata for yomo working. +func NewMetadata(sourceID, tid string, traceID string, spanID string, traced bool) metadata.M { return metadata.M{ MetadataSourceIDKey: sourceID, MetadataTIDKey: tid, - MetadataSIDKey: sid, - MetaTraced: tracedString, + MetadataTraceIDKey: traceID, + MetadataSpanIDKey: spanID, + MetaTracedKey: tracedString(traced), } } @@ -37,33 +42,124 @@ func GetTIDFromMetadata(m metadata.M) string { return tid } -// GetSIDFromMetadata gets SID from metadata. -func GetSIDFromMetadata(m metadata.M) string { - sid, _ := m.Get(MetadataSIDKey) - return sid -} - // GetTracedFromMetadata gets traced from metadata. func GetTracedFromMetadata(m metadata.M) bool { - traced, _ := m.Get(MetaTraced) - return traced == "true" + tracedString, _ := m.Get(MetaTracedKey) + return tracedString == "true" +} + +// SourceMetadata generates source metadata with trace information. +func SourceMetadata( + sourceID, tid string, + spanName string, // the span name usually is the source name. + tp oteltrace.TracerProvider, logger *slog.Logger, +) (metadata.M, func()) { + var ( + traceID string + spanID string + traced bool + endFn = func() {} + ) + if tp != nil { + span, err := trace.NewSpan(tp, "Source", spanName, "", "") + if err != nil { + logger.Debug("trace error", "tracer_name", "Source", "span_name", spanName, "err", err) + } else { + endFn = func() { span.End() } + traceID = span.SpanContext().TraceID().String() + spanID = span.SpanContext().SpanID().String() + traced = true + } + } + if traceID == "" { + logger.Debug("create new traceID", "tracer_name", "Source", "span_name", spanName, "trace_id", traceID) + traceID = id.NewTraceID() + } + if spanID == "" { + logger.Debug("create new spanID", "tracer_name", "Source", "span_name", spanName, "span_id", spanID) + spanID = id.NewSpanID() + } + logger.Debug( + "trace metadata", + "tracer_name", "Source", "span_name", spanName, + "trace_id", traceID, "span_id", spanID, "traced", traced, + ) + md := NewMetadata(sourceID, id.New(), traceID, spanID, traced) + + return md, endFn +} + +// ExtendTraceMetadata extends source metadata with trace information. +func ExtendTraceMetadata( + md metadata.M, + tracerName string, // the tracer name is `StreamFunction` or `Zipper`. + spanName string, // the span name usually is the sfn name. + tp oteltrace.TracerProvider, logger *slog.Logger, +) (metadata.M, func()) { + var ( + traceID, _ = md.Get(MetadataTraceIDKey) + spanID, _ = md.Get(MetadataSpanIDKey) + parentTraced = GetTracedFromMetadata(md) + endFn = func() {} + ) + traced := false + if tp != nil { + var span oteltrace.Span + var err error + // set parent span, if not traced, use empty string + if parentTraced { + span, err = trace.NewSpan(tp, string(tracerName), spanName, traceID, spanID) + } else { + span, err = trace.NewSpan(tp, string(tracerName), spanName, "", "") + } + if err != nil { + logger.Debug("trace error", "tracer_name", tracerName, "span_name", spanName, "err", err) + } else { + endFn = func() { span.End() } + traceID = span.SpanContext().TraceID().String() + spanID = span.SpanContext().SpanID().String() + traced = true + } + } + if traceID == "" { + logger.Debug("create new traceID", "tracer_name", tracerName, "span_name", spanName, "trace_id", traceID) + traceID = id.NewTraceID() + } + if spanID == "" { + logger.Debug("create new spanID", "tracer_name", tracerName, "span_name", spanName, "span_id", spanID) + spanID = id.NewSpanID() + } + logger.Debug( + "trace metadata", + "tracer_name", tracerName, "span_name", spanName, + "trace_id", traceID, "span_id", spanID, "traced", traced, "parent_traced", parentTraced, + ) + + if tracerName == "Zipper" { + traced = traced || parentTraced + } + + // reallocate metadata with new TraceID and SpanID + md.Set(MetadataTraceIDKey, traceID) + md.Set(MetadataSpanIDKey, spanID) + md.Set(MetaTracedKey, tracedString(traced)) + + return md, endFn } -// SetTIDToMetadata sets tid to metadata. -func SetTIDToMetadata(m metadata.M, tid string) { - m.Set(MetadataTIDKey, tid) +// SfnTraceMetadata extends metadata for StreamFunction. +func SfnTraceMetadata(md metadata.M, sfnName string, tp oteltrace.TracerProvider, logger *slog.Logger) (metadata.M, func()) { + return ExtendTraceMetadata(md, "StreamFunction", sfnName, tp, logger) } -// SetSIDToMetadata sets sid to metadata. -func SetSIDToMetadata(m metadata.M, sid string) { - m.Set(MetadataSIDKey, sid) +// ZipperTraceMetadata extends metadata for Zipper. +func ZipperTraceMetadata(md metadata.M, tp oteltrace.TracerProvider, logger *slog.Logger) (metadata.M, func()) { + return ExtendTraceMetadata(md, "Zipper", "zipper endpoint", tp, logger) } -// SetTracedToMetadata sets traced to metadata. -func SetTracedToMetadata(m metadata.M, traced bool) { - tracedString := "false" +func tracedString(traced bool) string { if traced { - tracedString = "true" + return "true" } - m.Set(MetaTraced, tracedString) + return "false" } diff --git a/core/metadata_test.go b/core/metadata_test.go index 9037e4891..cc2f2863b 100644 --- a/core/metadata_test.go +++ b/core/metadata_test.go @@ -7,19 +7,9 @@ import ( ) func TestMetadata(t *testing.T) { - md := NewDefaultMetadata("source", "xxxxxxx", "sssssss", true) + md := NewMetadata("source", "tid", "traceID", "spanID", true) assert.Equal(t, "source", GetSourceIDFromMetadata(md)) - assert.Equal(t, "xxxxxxx", GetTIDFromMetadata(md)) - assert.Equal(t, "sssssss", GetSIDFromMetadata(md)) + assert.Equal(t, "tid", GetTIDFromMetadata(md)) assert.Equal(t, true, GetTracedFromMetadata(md)) - - SetTIDToMetadata(md, "ccccccc") - assert.Equal(t, "ccccccc", GetTIDFromMetadata(md)) - - SetSIDToMetadata(md, "aaaaaaa") - assert.Equal(t, "aaaaaaa", GetSIDFromMetadata(md)) - - SetTracedToMetadata(md, false) - assert.Equal(t, false, GetTracedFromMetadata(md)) } diff --git a/core/server.go b/core/server.go index d34b1f0a0..a98b229fa 100644 --- a/core/server.go +++ b/core/server.go @@ -20,9 +20,7 @@ import ( // authentication implements, Currently, only token authentication is implemented _ "github.com/yomorun/yomo/pkg/auth" "github.com/yomorun/yomo/pkg/frame-codec/y3codec" - "github.com/yomorun/yomo/pkg/id" pkgtls "github.com/yomorun/yomo/pkg/tls" - "github.com/yomorun/yomo/pkg/trace" oteltrace "go.opentelemetry.io/otel/trace" ) @@ -345,51 +343,18 @@ func (s *Server) handleDataFrame(c *Context) error { // counter +1 atomic.AddInt64(&s.counterOfDataFrame, 1) - from := c.Connection - tid := GetTIDFromMetadata(c.FrameMetadata) - sid := GetSIDFromMetadata(c.FrameMetadata) - parentTraced := GetTracedFromMetadata(c.FrameMetadata) - traced := false - // trace - tp := s.TracerProvider() - if tp != nil { - // create span - var span oteltrace.Span - var err error - // set parent span, if not traced, use empty string - if parentTraced { - span, err = trace.NewSpan(tp, "zipper", "handle DataFrame", tid, sid) - } else { - span, err = trace.NewSpan(tp, "zipper", "handle DataFrame", "", "") - } - if err != nil { - s.logger.Error("zipper trace error", "err", err) - } else { - defer span.End() - tid = span.SpanContext().TraceID().String() - sid = span.SpanContext().SpanID().String() - traced = true - } - } - if tid == "" { - s.logger.Debug("zipper create new tid") - tid = id.TID() - } - if sid == "" { - s.logger.Debug("zipper create new sid") - sid = id.SID() - } - // reallocate metadata with new TID and SID - SetTIDToMetadata(c.FrameMetadata, tid) - SetSIDToMetadata(c.FrameMetadata, sid) - SetTracedToMetadata(c.FrameMetadata, traced || parentTraced) - md, err := c.FrameMetadata.Encode() + md, endFn := ZipperTraceMetadata(c.FrameMetadata, s.TracerProvider(), c.Logger) + defer endFn() + + c.FrameMetadata = md + + mdBytes, err := c.FrameMetadata.Encode() if err != nil { - s.logger.Error("encode metadata error", "err", err) + c.Logger.Error("encode metadata error", "err", err) return err } - dataFrame.Metadata = md - s.logger.Debug("zipper metadata", "tid", tid, "sid", sid, "parentTraced", parentTraced, "traced", traced, "frome_stream_name", from.Name()) + dataFrame.Metadata = mdBytes + // route route := s.router.Route(c.FrameMetadata) if route == nil { @@ -415,7 +380,7 @@ func (s *Server) handleDataFrame(c *Context) error { continue } - c.Logger.Info("data routing", "tid", tid, "sid", sid, "tag", dataFrame.Tag, "data_length", data_length, "to_id", toID, "to_name", stream.Name()) + c.Logger.Info("data routing", "tag", dataFrame.Tag, "data_length", data_length, "to_id", toID, "to_name", stream.Name()) // write data frame to stream if err := stream.WriteFrame(dataFrame); err != nil { @@ -512,10 +477,6 @@ func (s *Server) dispatchToDownstreams(c *Context) { return } - var ( - tid = GetTIDFromMetadata(c.FrameMetadata) - sid = GetSIDFromMetadata(c.FrameMetadata) - ) mdBytes, err := c.FrameMetadata.Encode() if err != nil { c.Logger.Error("failed to dispatch to downstream", "err", err) @@ -526,9 +487,9 @@ func (s *Server) dispatchToDownstreams(c *Context) { for _, ds := range s.downstreams { c.Logger.Info( "dispatching to downstream", - "tid", tid, "sid", sid, "tag", dataFrame.Tag, "data_length", len(dataFrame.Payload), - "downstream_id", ds.ID(), "downstream_name", ds.LocalName(), - ) + "tag", dataFrame.Tag, "data_length", len(dataFrame.Payload), + "downstream_id", ds.ID(), "downstream_name", ds.LocalName()) + _ = ds.WriteFrame(dataFrame) } } diff --git a/pkg/id/id.go b/pkg/id/id.go index 5a0ba32e5..99abc0178 100644 --- a/pkg/id/id.go +++ b/pkg/id/id.go @@ -19,8 +19,8 @@ func New(l ...int) string { return tid } -// TID generate trace id. -func TID() string { +// NewTraceID returns a trace id. +func NewTraceID() string { bytes := make([]byte, 16) if _, err := rand.Read(bytes); err != nil { return "" @@ -28,8 +28,8 @@ func TID() string { return hex.EncodeToString(bytes) } -// SID generate span id. -func SID() string { +// NewSpanID returns a span id. +func NewSpanID() string { bytes := make([]byte, 8) if _, err := rand.Read(bytes); err != nil { return "" diff --git a/pkg/id/id_test.go b/pkg/id/id_test.go index 0467cfda7..56a5116d2 100644 --- a/pkg/id/id_test.go +++ b/pkg/id/id_test.go @@ -7,14 +7,20 @@ import ( ) func TestNew(t *testing.T) { - str := New() - assert.IsType(t, "", str) + t.Run("new a random id", func(t *testing.T) { + str := New() + assert.IsType(t, "", str) + }) - tid := TID() - assert.IsType(t, "", tid) - assert.Equal(t, 32, len(tid)) + t.Run("new trace id", func(t *testing.T) { + traceID := NewTraceID() + assert.IsType(t, "", traceID) + assert.Equal(t, 32, len(traceID)) + }) - sid := SID() - assert.IsType(t, "", sid) - assert.Equal(t, 16, len(sid)) + t.Run("new span id", func(t *testing.T) { + spanID := NewSpanID() + assert.IsType(t, "", spanID) + assert.Equal(t, 16, len(spanID)) + }) } diff --git a/sfn.go b/sfn.go index 364ef38b4..78dab943f 100644 --- a/sfn.go +++ b/sfn.go @@ -8,10 +8,7 @@ import ( "github.com/yomorun/yomo/core/frame" "github.com/yomorun/yomo/core/metadata" "github.com/yomorun/yomo/core/serverless" - "github.com/yomorun/yomo/pkg/id" - "github.com/yomorun/yomo/pkg/trace" oteltrace "go.opentelemetry.io/otel/trace" - "golang.org/x/exp/slog" ) // StreamFunction defines serverless streaming functions. @@ -130,8 +127,8 @@ func (s *streamFunction) Connect() error { break } - newMd, deferFunc := ExtendTraceMetadata(md, s.client.ClientID(), s.client.Name(), s.client.TracerProvider(), s.client.Logger) - defer deferFunc() + newMd, endFn := core.SfnTraceMetadata(md, s.client.Name(), s.client.TracerProvider(), s.client.Logger) + defer endFn() newMetadata, err := newMd.Encode() if err != nil { @@ -193,8 +190,8 @@ func (s *streamFunction) onDataFrame(dataFrame *frame.DataFrame) { return } - newMd, deferFunc := ExtendTraceMetadata(md, s.client.ClientID(), s.client.Name(), s.client.TracerProvider(), s.client.Logger) - defer deferFunc() + newMd, endFn := core.SfnTraceMetadata(md, s.client.Name(), s.client.TracerProvider(), s.client.Logger) + defer endFn() newMetadata, err := newMd.Encode() if err != nil { @@ -224,48 +221,3 @@ func (s *streamFunction) SetErrorHandler(fn func(err error)) { func (s *streamFunction) Init(fn func() error) error { return fn() } - -// ExtendTraceMetadata extends source trace metadata. -func ExtendTraceMetadata(md metadata.M, clientID, name string, tp oteltrace.TracerProvider, logger *slog.Logger) (metadata.M, func()) { - deferFunc := func() {} - tid := core.GetTIDFromMetadata(md) - sid := core.GetSIDFromMetadata(md) - parentTraced := core.GetTracedFromMetadata(md) - traced := false - // trace - if tp != nil { - // create span - var span oteltrace.Span - var err error - // set parent span, if not traced, use empty string - if parentTraced { - span, err = trace.NewSpan(tp, core.ClientTypeStreamFunction.String(), name, tid, sid) - } else { - span, err = trace.NewSpan(tp, core.ClientTypeStreamFunction.String(), name, "", "") - } - if err != nil { - logger.Error("sfn trace error", "err", err) - } else { - deferFunc = func() { span.End() } - tid = span.SpanContext().TraceID().String() - sid = span.SpanContext().SpanID().String() - traced = true - } - } - if tid == "" { - logger.Debug("sfn create new tid") - tid = id.TID() - } - if sid == "" || !traced { - logger.Debug("sfn create new sid") - sid = id.SID() - } - // reallocate metadata with new TID and SID - core.SetTIDToMetadata(md, tid) - core.SetSIDToMetadata(md, sid) - core.SetTracedToMetadata(md, traced) - - logger.Debug("sfn metadata", "tid", tid, "sid", sid, "parentTraced", parentTraced, "traced", traced) - - return md, deferFunc -} diff --git a/source.go b/source.go index 61718f807..84a93465d 100644 --- a/source.go +++ b/source.go @@ -5,11 +5,7 @@ import ( "github.com/yomorun/yomo/core" "github.com/yomorun/yomo/core/frame" - "github.com/yomorun/yomo/core/metadata" "github.com/yomorun/yomo/pkg/id" - "github.com/yomorun/yomo/pkg/trace" - oteltrace "go.opentelemetry.io/otel/trace" - "golang.org/x/exp/slog" ) // Source is responsible for sending data to yomo. @@ -84,7 +80,7 @@ func (s *yomoSource) Connect() error { // Write writes data with specified tag. func (s *yomoSource) Write(tag uint32, data []byte) error { - md, deferFunc := TraceMetadata(s.client.ClientID(), s.name, s.client.TracerProvider(), s.client.Logger) + md, deferFunc := core.SourceMetadata(s.client.ClientID(), id.New(), s.name, s.client.TracerProvider(), s.client.Logger) defer deferFunc() mdBytes, err := md.Encode() @@ -111,35 +107,3 @@ func (s *yomoSource) SetReceiveHandler(fn func(uint32, []byte)) { s.fn = fn s.client.Logger.Info("receive hander set for the source") } - -// TraceMetadata generates source trace metadata. -func TraceMetadata(clientID, name string, tp oteltrace.TracerProvider, logger *slog.Logger) (metadata.M, func()) { - deferFunc := func() {} - var tid, sid string - // trace - traced := false - if tp != nil { - span, err := trace.NewSpan(tp, core.ClientTypeSource.String(), name, "", "") - if err != nil { - logger.Error("source trace error", "err", err) - } else { - deferFunc = func() { span.End() } - tid = span.SpanContext().TraceID().String() - sid = span.SpanContext().SpanID().String() - traced = true - } - } - if tid == "" { - logger.Debug("source create new tid") - tid = id.TID() - } - if sid == "" { - logger.Debug("source create new sid") - sid = id.SID() - } - logger.Debug("source metadata", "tid", tid, "sid", sid, "traced", traced) - - md := core.NewDefaultMetadata(clientID, tid, sid, traced) - - return md, deferFunc -} From 92b21e79c6e7f40b65fd171b95c84922da761c63 Mon Sep 17 00:00:00 2001 From: "C.C" Date: Mon, 23 Oct 2023 11:25:57 +0800 Subject: [PATCH 05/12] fix security issue #9 (#653) fix https://github.com/yomorun/yomo/security/dependabot/9 --- docs/package.json | 2 +- docs/pnpm-lock.yaml | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/package.json b/docs/package.json index 9b3709410..52389810e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -33,7 +33,7 @@ "@types/node": "18.15.11", "autoprefixer": "^10.4.14", "next-sitemap": "^4.0.7", - "postcss": "^8.4.21", + "postcss": "^8.4.31", "tailwindcss": "^3.3.1", "typescript": "5.0.4" }, diff --git a/docs/pnpm-lock.yaml b/docs/pnpm-lock.yaml index af793ae70..f078e504e 100644 --- a/docs/pnpm-lock.yaml +++ b/docs/pnpm-lock.yaml @@ -54,16 +54,16 @@ devDependencies: version: 18.15.11 autoprefixer: specifier: ^10.4.14 - version: 10.4.14(postcss@8.4.21) + version: 10.4.14(postcss@8.4.31) next-sitemap: specifier: ^4.0.7 version: 4.0.7(@next/env@13.3.0)(next@13.3.0) postcss: - specifier: ^8.4.21 - version: 8.4.21 + specifier: ^8.4.31 + version: 8.4.31 tailwindcss: specifier: ^3.3.1 - version: 3.3.1(postcss@8.4.21) + version: 3.3.1(postcss@8.4.31) typescript: specifier: 5.0.4 version: 5.0.4 @@ -578,7 +578,7 @@ packages: hasBin: true dev: false - /autoprefixer@10.4.14(postcss@8.4.21): + /autoprefixer@10.4.14(postcss@8.4.31): resolution: {integrity: sha512-FQzyfOsTlwVzjHxKEqRIAdJx9niO6VCBCoEwax/VLSoQF29ggECcPuBqUMZ+u8jCZOPSy8b8/8KnuFbp0SaFZQ==} engines: {node: ^10 || ^12 || >=14} hasBin: true @@ -590,7 +590,7 @@ packages: fraction.js: 4.2.0 normalize-range: 0.1.2 picocolors: 1.0.0 - postcss: 8.4.21 + postcss: 8.4.31 postcss-value-parser: 4.2.0 dev: true @@ -2611,29 +2611,29 @@ packages: engines: {node: '>= 6'} dev: true - /postcss-import@14.1.0(postcss@8.4.21): + /postcss-import@14.1.0(postcss@8.4.31): resolution: {integrity: sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==} engines: {node: '>=10.0.0'} peerDependencies: postcss: ^8.0.0 dependencies: - postcss: 8.4.21 + postcss: 8.4.31 postcss-value-parser: 4.2.0 read-cache: 1.0.0 resolve: 1.22.2 dev: true - /postcss-js@4.0.1(postcss@8.4.21): + /postcss-js@4.0.1(postcss@8.4.31): resolution: {integrity: sha512-dDLF8pEO191hJMtlHFPRa8xsizHaM82MLfNkUHdUtVEV3tgTp5oj+8qbEqYM57SLfc74KSbw//4SeJma2LRVIw==} engines: {node: ^12 || ^14 || >= 16} peerDependencies: postcss: ^8.4.21 dependencies: camelcase-css: 2.0.1 - postcss: 8.4.21 + postcss: 8.4.31 dev: true - /postcss-load-config@3.1.4(postcss@8.4.21): + /postcss-load-config@3.1.4(postcss@8.4.31): resolution: {integrity: sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==} engines: {node: '>= 10'} peerDependencies: @@ -2646,17 +2646,17 @@ packages: optional: true dependencies: lilconfig: 2.1.0 - postcss: 8.4.21 + postcss: 8.4.31 yaml: 1.10.2 dev: true - /postcss-nested@6.0.0(postcss@8.4.21): + /postcss-nested@6.0.0(postcss@8.4.31): resolution: {integrity: sha512-0DkamqrPcmkBDsLn+vQDIrtkSbNkv5AD/M322ySo9kqFkCIYklym2xEmWkwo+Y3/qZo34tzEPNUw4y7yMCdv5w==} engines: {node: '>=12.0'} peerDependencies: postcss: ^8.2.14 dependencies: - postcss: 8.4.21 + postcss: 8.4.31 postcss-selector-parser: 6.0.11 dev: true @@ -2679,8 +2679,8 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.2 - /postcss@8.4.21: - resolution: {integrity: sha512-tP7u/Sn/dVxK2NnruI4H9BG+x+Wxz6oeZ1cJ8P6G/PZY0IKk4k/63TDsQf2kQq3+qoJeLm2kIBUNlZe3zgb4Zg==} + /postcss@8.4.31: + resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.6 @@ -3062,7 +3062,7 @@ packages: engines: {node: '>= 0.4'} dev: true - /tailwindcss@3.3.1(postcss@8.4.21): + /tailwindcss@3.3.1(postcss@8.4.31): resolution: {integrity: sha512-Vkiouc41d4CEq0ujXl6oiGFQ7bA3WEhUZdTgXAhtKxSy49OmKs8rEfQmupsfF0IGW8fv2iQkp1EVUuapCFrZ9g==} engines: {node: '>=12.13.0'} hasBin: true @@ -3083,11 +3083,11 @@ packages: normalize-path: 3.0.0 object-hash: 3.0.0 picocolors: 1.0.0 - postcss: 8.4.21 - postcss-import: 14.1.0(postcss@8.4.21) - postcss-js: 4.0.1(postcss@8.4.21) - postcss-load-config: 3.1.4(postcss@8.4.21) - postcss-nested: 6.0.0(postcss@8.4.21) + postcss: 8.4.31 + postcss-import: 14.1.0(postcss@8.4.31) + postcss-js: 4.0.1(postcss@8.4.31) + postcss-load-config: 3.1.4(postcss@8.4.31) + postcss-nested: 6.0.0(postcss@8.4.31) postcss-selector-parser: 6.0.11 postcss-value-parser: 4.2.0 quick-lru: 5.1.1 From 1754f265835be9288f686979532b15e4466a1591 Mon Sep 17 00:00:00 2001 From: wurui Date: Mon, 30 Oct 2023 15:06:03 +0800 Subject: [PATCH 06/12] feat: zipper support middleware (#660) # Description Adding `WithConnMiddleware()` and `WithFrameMiddleware()` zipper option, their type is below: ```go type ( // FrameHandler handles a frame. FrameHandler func(*Context) // FrameMiddleware is a middleware for frame handler. FrameMiddleware func(FrameHandler) FrameHandler ) type ( // ConnHandler handles a connection and route. ConnHandler func(*Connection, router.Route) // ConnMiddleware is a middleware for connection handler. ConnMiddleware func(ConnHandler) ConnHandler ) ``` --------- Co-authored-by: venjiang Co-authored-by: C.C --- core/client_test.go | 56 +++++----- core/connection.go | 57 ++++++---- core/connection_test.go | 3 +- core/connector.go | 26 ++--- core/connector_test.go | 11 +- core/context.go | 60 ++++------ core/server.go | 240 ++++++++++++++++++---------------------- core/server_options.go | 26 ++++- options.go | 14 +++ zipper.go | 4 +- 10 files changed, 249 insertions(+), 248 deletions(-) diff --git a/core/client_test.go b/core/client_test.go index af2a1a8c7..6cefd80a6 100644 --- a/core/client_test.go +++ b/core/client_test.go @@ -45,24 +45,23 @@ func TestFrameRoundTrip(t *testing.T) { backflow = []byte("hello backflow frame") ) + // test server hooks + ht := &hookTester{t: t} + server := NewServer("zipper", WithAuth("token", "auth-token"), WithServerQuicConfig(DefalutQuicConfig), WithServerTLSConfig(nil), WithServerLogger(discardingLogger), + WithConnMiddleware(ht.connMiddleware), + WithFrameMiddleware(ht.frameMiddleware), ) server.ConfigRouter(router.Default()) - // test server hooks - ht := &hookTester{t} - server.SetStartHandlers(ht.startHandler) - server.SetBeforeHandlers(ht.beforeHandler) - server.SetAfterHandlers(ht.afterHandler) - recorder := newFrameWriterRecorder("mockID", "mockClientLocal", "mockClientRemote") server.AddDownstreamServer(recorder) - assert.Equal(t, server.Downstreams()["mockID"], recorder.ID()) + assert.Equal(t, server.Downstreams()["mockClientLocal"], recorder.ID()) go func() { err := server.ListenAndServe(ctx, testaddr) @@ -191,29 +190,36 @@ func checkClientExited(client *Client, tim time.Duration) bool { } type hookTester struct { - t *testing.T -} - -func (a *hookTester) startHandler(ctx *Context) error { - ctx.Set("start", "yes") - return nil + mu sync.Mutex + connNames []string + t *testing.T } -func (a *hookTester) beforeHandler(ctx *Context) error { - ctx.Set("before", "ok") - return nil -} +func (a *hookTester) connMiddleware(next ConnHandler) ConnHandler { + return func(c *Connection, r router.Route) { + a.mu.Lock() + if a.connNames == nil { + a.connNames = make([]string, 0) + } + a.connNames = append(a.connNames, c.Name()) + a.mu.Unlock() -func (a *hookTester) afterHandler(ctx *Context) error { - v, ok := ctx.Get("start") - assert.True(a.t, ok) - assert.Equal(a.t, v, "yes") + next(c, r) - v = ctx.Value("before") - assert.True(a.t, ok) - assert.Equal(a.t, v, "ok") + a.mu.Lock() + assert.Contains(a.t, a.connNames, c.Name()) + a.mu.Unlock() + } +} - return nil +func (a *hookTester) frameMiddleware(next FrameHandler) FrameHandler { + return func(c *Context) { + c.Set("a", "b") + next(c) + v, ok := c.Get("a") + assert.True(a.t, ok) + assert.Equal(a.t, "b", v) + } } func createTestStreamFunction(name string, zipperAddr string, observedTag frame.Tag) *Client { diff --git a/core/connection.go b/core/connection.go index 87244e3b6..7fb638202 100644 --- a/core/connection.go +++ b/core/connection.go @@ -6,6 +6,7 @@ import ( "github.com/quic-go/quic-go" "github.com/yomorun/yomo/core/frame" "github.com/yomorun/yomo/core/metadata" + "golang.org/x/exp/slog" ) // ConnectionInfo holds the information of connection. @@ -22,17 +23,9 @@ type ConnectionInfo interface { ObserveDataTags() []frame.Tag } -// Connection wraps conneciton and stream to transfer frames. -// Connection be used to read and write frames, and be managed by Connector. -type Connection interface { - Context() context.Context - ConnectionInfo - frame.ReadWriteCloser - // CloseWithError closes the connection with an error string. - CloseWithError(string) error -} - -type connection struct { +// Connection wraps connection and stream for transmitting frames, it can be +// used for reading and writing frames, and is managed by the Connector. +type Connection struct { name string id string clientType ClientType @@ -40,12 +33,19 @@ type connection struct { observeDataTags []uint32 conn quic.Connection fs *FrameStream + Logger *slog.Logger } func newConnection( name string, id string, clientType ClientType, md metadata.M, tags []uint32, - conn quic.Connection, fs *FrameStream) *connection { - return &connection{ + conn quic.Connection, fs *FrameStream, logger *slog.Logger) *Connection { + + logger = logger.With("conn_id", id, "conn_name", name) + if conn != nil { + logger.Info("new client connected", "remote_addr", conn.RemoteAddr().String(), "client_type", clientType.String()) + } + + return &Connection{ name: name, id: id, clientType: clientType, @@ -53,46 +53,57 @@ func newConnection( observeDataTags: tags, conn: conn, fs: fs, + Logger: logger, } } -func (c *connection) Close() error { +// Close closes the connection. +func (c *Connection) Close() error { return c.fs.Close() } -func (c *connection) Context() context.Context { +// Context returns the context of the connection. +func (c *Connection) Context() context.Context { return c.fs.Context() } -func (c *connection) ID() string { +// ID returns the connection ID. +func (c *Connection) ID() string { return c.id } -func (c *connection) Metadata() metadata.M { +// Metadata returns the extra info of the application. +func (c *Connection) Metadata() metadata.M { return c.metadata } -func (c *connection) Name() string { +// Name returns the name of the connection +func (c *Connection) Name() string { return c.name } -func (c *connection) ObserveDataTags() []uint32 { +// ObserveDataTags returns the observed data tags. +func (c *Connection) ObserveDataTags() []uint32 { return c.observeDataTags } -func (c *connection) ReadFrame() (frame.Frame, error) { +// ReadFrame reads a frame from the connection. +func (c *Connection) ReadFrame() (frame.Frame, error) { return c.fs.ReadFrame() } -func (c *connection) ClientType() ClientType { +// ClientType returns the client type of the connection. +func (c *Connection) ClientType() ClientType { return c.clientType } -func (c *connection) WriteFrame(f frame.Frame) error { +// WriteFrame writes a frame to the connection. +func (c *Connection) WriteFrame(f frame.Frame) error { return c.fs.WriteFrame(f) } -func (c *connection) CloseWithError(errString string) error { +// CloseWithError closes the connection with error. +func (c *Connection) CloseWithError(errString string) error { return c.conn.CloseWithError(YomoCloseErrorCode, errString) } diff --git a/core/connection_test.go b/core/connection_test.go index 64ad111c2..ae72d8960 100644 --- a/core/connection_test.go +++ b/core/connection_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/yomorun/yomo/core/frame" "github.com/yomorun/yomo/core/metadata" + "golang.org/x/exp/slog" ) func TestConnection(t *testing.T) { @@ -30,7 +31,7 @@ func TestConnection(t *testing.T) { // create frame connection. fs := NewFrameStream(mockStream, &byteCodec{}, &bytePacketReadWriter{}) - connection := newConnection(name, id, styp, md, observed, nil, fs) + connection := newConnection(name, id, styp, md, observed, nil, fs, slog.Default()) t.Run("ConnectionInfo", func(t *testing.T) { assert.Equal(t, id, connection.ID()) diff --git a/core/connector.go b/core/connector.go index ac2a70578..fe229a3d6 100644 --- a/core/connector.go +++ b/core/connector.go @@ -32,7 +32,7 @@ func NewConnector(ctx context.Context) *Connector { // Store stores Connection to Connector, // If the connID is the same twice, the new connection will replace the old connection. // If Connector be closed, The function will return ErrConnectorClosed. -func (c *Connector) Store(connID string, conn Connection) error { +func (c *Connector) Store(connID string, conn *Connection) error { select { case <-c.ctx.Done(): return ErrConnectorClosed @@ -62,7 +62,7 @@ func (c *Connector) Remove(connID string) error { // Get retrieves the Connection with the specified connID. // If the Connector does not have a connection with the given connID, return nil and false. // If Connector be closed, The function will return ErrConnectorClosed. -func (c *Connector) Get(connID string) (Connection, bool, error) { +func (c *Connector) Get(connID string) (*Connection, bool, error) { select { case <-c.ctx.Done(): return nil, false, ErrConnectorClosed @@ -74,9 +74,7 @@ func (c *Connector) Get(connID string) (Connection, bool, error) { return nil, false, nil } - connection := v.(Connection) - - return connection, true, nil + return v.(*Connection), true, nil } // FindConnectionFunc is used to search for a specific connection within the Connector. @@ -84,19 +82,19 @@ type FindConnectionFunc func(ConnectionInfo) bool // Find searches a stream collection using the specified find function. // If Connector be closed, The function will return ErrConnectorClosed. -func (c *Connector) Find(findFunc FindConnectionFunc) ([]Connection, error) { +func (c *Connector) Find(findFunc FindConnectionFunc) ([]*Connection, error) { select { case <-c.ctx.Done(): - return []Connection{}, ErrConnectorClosed + return []*Connection{}, ErrConnectorClosed default: } - connections := make([]Connection, 0) + connections := make([]*Connection, 0) c.connections.Range(func(key interface{}, val interface{}) bool { - stream := val.(Connection) + conn := val.(*Connection) - if findFunc(stream) { - connections = append(connections, stream) + if findFunc(conn) { + connections = append(connections, conn) } return true }) @@ -112,10 +110,10 @@ func (c *Connector) Snapshot() map[string]string { c.connections.Range(func(key interface{}, val interface{}) bool { var ( - streamID = key.(string) - stream = val.(Connection) + connID = key.(string) + conn = val.(*Connection) ) - result[streamID] = stream.Name() + result[connID] = conn.Name() return true }) diff --git a/core/connector_test.go b/core/connector_test.go index d6a8efe67..e8822099f 100644 --- a/core/connector_test.go +++ b/core/connector_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/yomorun/yomo/core/frame" + "golang.org/x/exp/slog" ) func TestConnector(t *testing.T) { @@ -37,10 +38,9 @@ func TestConnector(t *testing.T) { err = connector.Remove(connID) assert.NoError(t, err) - gotStream, ok, err := connector.Get(connID) + _, ok, err := connector.Get(connID) assert.NoError(t, err) assert.False(t, ok) - assert.Equal(t, gotStream, nil) }) t.Run("Find", func(t *testing.T) { @@ -92,9 +92,8 @@ func TestConnector(t *testing.T) { t.Run("Get", func(t *testing.T) { conn1 := mockConn("id-1", "name-1") - gotStream, ok, err := connector.Get(conn1.ID()) + _, ok, err := connector.Get(conn1.ID()) assert.False(t, ok) - assert.Equal(t, gotStream, nil) assert.ErrorIs(t, err, ErrConnectorClosed) }) @@ -117,6 +116,6 @@ func TestConnector(t *testing.T) { // mockConn returns a connection that only includes an ID and a name. // This function is used for unit testing purposes. -func mockConn(id, name string) Connection { - return newConnection(name, id, ClientType(0), nil, []frame.Tag{0}, nil, nil) +func mockConn(id, name string) *Connection { + return newConnection(name, id, ClientType(0), nil, []frame.Tag{0}, nil, nil, slog.Default()) } diff --git a/core/context.go b/core/context.go index 9bdb42a4d..986456ceb 100644 --- a/core/context.go +++ b/core/context.go @@ -13,14 +13,13 @@ import ( var ctxPool sync.Pool -// Context is context for connection handling. -// Context is generated subsequent to the arrival of a connection and retains pertinent information derived from the connection. -// The lifespan of the Context should align with the lifespan of the connection. +// Context is context for frame handling. +// The lifespan of the Context should align with the lifespan of the frame. type Context struct { // Connection is the connection used for reading and writing frames. - Connection Connection + Connection *Connection // Frame receives from client. - Frame frame.Frame + Frame *frame.DataFrame // FrameMetadata is the merged metadata from the frame. FrameMetadata metadata.M // Route is the route from handshake. @@ -29,8 +28,6 @@ type Context struct { mu sync.RWMutex // Keys stores the key/value pairs in context, It is Lazy initialized. Keys map[string]any - // BaseLogger is the base logger. - BaseLogger *slog.Logger // Using Logger to log in connection handler scope, Logger is frame-level logger. Logger *slog.Logger } @@ -89,53 +86,35 @@ func (c *Context) Value(key any) any { // The YoMo context is used to manage the lifecycle of a connection and provides a way to pass data and metadata // between connection processing functions. The lifecycle of the context is equal to the lifecycle of the connection // that it is associated with. The context can be used to manage timeouts, cancellations, and other aspects of connection processing. -func newContext(conn Connection, route router.Route, logger *slog.Logger) (c *Context) { - v := ctxPool.Get() - if v == nil { - c = new(Context) - } else { - c = v.(*Context) - } - - c.Connection = conn - c.Route = route - c.BaseLogger = logger - c.Logger = logger - - return -} - -// WithFrame sets the current frame of the YoMo context to the given frame. -// It extracts the metadata from the data frame and sets it as attributes on the context logger. -// It also merges the metadata from the connection with the metadata from the data frame. -// This allows downstream processing functions to access the metadata from both the connection and the current data frame. -// If the given frame is not a data frame, it returns an error. -// If there is an error decoding the metadata from the data frame, it returns that error. -// Otherwise, it sets the current frame and frame metadata on the context and returns nil. -func (c *Context) WithFrame(f frame.Frame) error { - df, ok := f.(*frame.DataFrame) - if !ok { - return nil - } - +func newContext(conn *Connection, route router.Route, df *frame.DataFrame) (c *Context, err error) { fmd, err := metadata.Decode(df.Metadata) if err != nil { - return err + return nil, err } // merge connection metadata. - c.Connection.Metadata().Range(func(k, v string) bool { + conn.Metadata().Range(func(k, v string) bool { fmd.Set(k, v) return true }) + v := ctxPool.Get() + if v == nil { + c = new(Context) + } else { + c = v.(*Context) + } + c.Frame = df c.FrameMetadata = fmd + c.Connection = conn + c.Route = route + // log with tid - c.Logger = c.BaseLogger.With("tid", GetTIDFromMetadata(fmd)) + c.Logger = c.Connection.Logger.With("tid", GetTIDFromMetadata(fmd)) - return nil + return } // CloseWithError close dataStream with an error string. @@ -162,7 +141,6 @@ func (c *Context) reset() { c.Route = nil c.Frame = nil c.FrameMetadata = nil - c.BaseLogger = nil c.Logger = nil for k := range c.Keys { delete(c.Keys, k) diff --git a/core/server.go b/core/server.go index a98b229fa..7ec7be1b6 100644 --- a/core/server.go +++ b/core/server.go @@ -27,32 +27,38 @@ import ( // ErrServerClosed is returned by the Server's Serve and ListenAndServe methods after a call to Shutdown or Close. var ErrServerClosed = errors.New("yomo: Server closed") -// FrameHandler is the handler for frame. -type FrameHandler func(c *Context) error +type ( + // FrameHandler handles a frame. + FrameHandler func(*Context) + // FrameMiddleware is a middleware for frame handler. + FrameMiddleware func(FrameHandler) FrameHandler +) -// ConnectionHandler is the handler for quic connection -type ConnectionHandler func(conn quic.Connection) +type ( + // ConnHandler handles a connection and route. + ConnHandler func(*Connection, router.Route) + // ConnMiddleware is a middleware for connection handler. + ConnMiddleware func(ConnHandler) ConnHandler +) // Server is the underlying server of Zipper type Server struct { - ctx context.Context - ctxCancel context.CancelFunc - name string - connector *Connector - router router.Router - codec frame.Codec - packetReadWriter frame.PacketReadWriter - counterOfDataFrame int64 - downstreams map[string]Downstream - mu sync.Mutex - opts *serverOptions - startHandlers []FrameHandler - beforeHandlers []FrameHandler - afterHandlers []FrameHandler - connectionCloseHandlers []ConnectionHandler - listener *quic.Listener - logger *slog.Logger - tracerProvider oteltrace.TracerProvider + ctx context.Context + ctxCancel context.CancelFunc + name string + connector *Connector + router router.Router + codec frame.Codec + packetReadWriter frame.PacketReadWriter + counterOfDataFrame int64 + downstreams map[string]Downstream + mu sync.Mutex + opts *serverOptions + frameHandler FrameHandler + connHandler ConnHandler + listener *quic.Listener + logger *slog.Logger + tracerProvider oteltrace.TracerProvider } // NewServer create a Server instance. @@ -79,6 +85,10 @@ func NewServer(name string, opts ...ServerOption) *Server { opts: options, } + // work with middleware. + s.connHandler = composeConnHandler(s.handleConnRoute, s.opts.connMiddlewares...) + s.frameHandler = composeFrameHandler(s.handleFrame, s.opts.frameMiddlewares...) + return s } @@ -101,7 +111,7 @@ func (s *Server) ListenAndServe(ctx context.Context, addr string) error { return s.Serve(ctx, conn) } -func (s *Server) handshake(qconn quic.Connection, fs *FrameStream) (bool, router.Route, Connection) { +func (s *Server) handshake(qconn quic.Connection, fs *FrameStream) (bool, router.Route, *Connection) { var gerr error defer func() { @@ -128,7 +138,7 @@ func (s *Server) handshake(qconn quic.Connection, fs *FrameStream) (bool, router return false, nil, conn } - route, err := s.handleRoute(hf, conn.Metadata()) + route, err := s.addSfnToRoute(hf, conn.Metadata()) if err != nil { gerr = err } @@ -139,77 +149,47 @@ func (s *Server) handshake(qconn quic.Connection, fs *FrameStream) (bool, router } } -func (s *Server) handleConnection(qconn quic.Connection, fs *FrameStream, logger *slog.Logger) { - ok, route, conn := s.handshake(qconn, fs) - if !ok { - logger.Error("handshake failed") - return - } - - logger = logger.With("conn_id", conn.ID(), "conn_name", conn.Name()) - logger.Info("new client connected", "remote_addr", qconn.RemoteAddr().String(), "client_type", conn.ClientType().String()) - - c := newContext(conn, route, logger) - - s.handleContext(c) -} - -func (s *Server) handleContext(c *Context) { - for _, h := range s.startHandlers { - if err := h(c); err != nil { - c.CloseWithError(err.Error()) - } - } - - go s.handleFrames(c) -} - -func (s *Server) handleFrames(c *Context) { +func (s *Server) handleConnRoute(conn *Connection, route router.Route) { defer func() { - if c.Connection.ClientType() == ClientTypeStreamFunction { - _ = c.Route.Remove(c.Connection.ID()) + if conn.ClientType() == ClientTypeStreamFunction { + _ = route.Remove(conn.ID()) } - _ = s.connector.Remove(c.Connection.ID()) - c.Release() + _ = s.connector.Remove(conn.ID()) }() for { - f, err := c.Connection.ReadFrame() + f, err := conn.ReadFrame() if err != nil { - c.Logger.Info("failed to read frame", "err", err) + conn.Logger.Info("failed to read frame", "err", err) return } - - if err := c.WithFrame(f); err != nil { - c.CloseWithError(err.Error()) - return - } - - for _, h := range s.beforeHandlers { - if err := h(c); err != nil { - c.CloseWithError(err.Error()) - return - } - } - switch f.Type() { case frame.TypeDataFrame: - if err := s.mainFrameHandler(c); err != nil { - c.Logger.Info("failed to handle data frame", "err", err) + c, err := newContext(conn, route, f.(*frame.DataFrame)) + if err != nil { + conn.Logger.Info("failed to new context", "err", err) return } - } + defer c.Release() - for _, h := range s.afterHandlers { - if err := h(c); err != nil { - c.CloseWithError(err.Error()) - return - } + s.frameHandler(c) + default: + conn.Logger.Info("unexpected frame", "type", f.Type().String()) + return } } +} +func (s *Server) handleQuicConnection(qconn quic.Connection, fs *FrameStream, logger *slog.Logger) { + ok, route, conn := s.handshake(qconn, fs) + if !ok { + logger.Error("handshake failed") + return + } + + s.connHandler(conn, route) } -func (s *Server) handleRoute(hf *frame.HandshakeFrame, md metadata.M) (router.Route, error) { +func (s *Server) addSfnToRoute(hf *frame.HandshakeFrame, md metadata.M) (router.Route, error) { if hf.ClientType != byte(ClientTypeStreamFunction) { return nil, nil } @@ -224,15 +204,19 @@ func (s *Server) handleRoute(hf *frame.HandshakeFrame, md metadata.M) (router.Ro return route, nil } -func (s *Server) handleHandshakeFrame(qconn quic.Connection, fs *FrameStream, hf *frame.HandshakeFrame) (Connection, error) { +func (s *Server) handleHandshakeFrame(qconn quic.Connection, fs *FrameStream, hf *frame.HandshakeFrame) (*Connection, error) { md, ok := auth.Authenticate(s.opts.auths, hf) if !ok { - s.logger.Warn("authentication failed", "credential", hf.AuthName) + s.logger.Warn( + "authentication failed", + "client_type", ClientType(hf.ClientType).String(), "client_name", hf.Name, + "credential", hf.AuthName, + ) return nil, fmt.Errorf("authentication failed: client credential name is %s", hf.AuthName) } - conn := newConnection(hf.Name, hf.ID, ClientType(hf.ClientType), md, hf.ObserveDataTags, qconn, fs) + conn := newConnection(hf.Name, hf.ID, ClientType(hf.ClientType), md, hf.ObserveDataTags, qconn, fs, s.logger) return conn, s.connector.Store(hf.ID, conn) } @@ -283,7 +267,7 @@ func (s *Server) Serve(ctx context.Context, conn net.PacketConn) error { fs := NewFrameStream(stream, y3codec.Codec(), y3codec.PacketReadWriter()) - go s.handleConnection(qconn, fs, s.logger) + go s.handleQuicConnection(qconn, fs, s.logger) } } @@ -317,27 +301,28 @@ func closeServer(downstreams map[string]Downstream, connector *Connector, listen return nil } -func (s *Server) mainFrameHandler(c *Context) error { - frameType := c.Frame.Type() +func (s *Server) handleFrame(c *Context) { + // routing data frame. + if err := s.routingDataFrame(c); err != nil { + c.CloseWithError(fmt.Sprintf("handle dataFrame err: %v", err)) + return + } - switch frameType { - case frame.TypeDataFrame: - if err := s.handleDataFrame(c); err != nil { - c.CloseWithError(fmt.Sprintf("handle dataFrame err: %v", err)) - } else { - s.dispatchToDownstreams(c) + // dispatch to downstream. + if err := s.dispatchToDownstreams(c); err != nil { + c.CloseWithError(fmt.Sprintf("dispatch to downstream err: %v", err)) + return + } - // observe datatags backflow - s.handleBackflowFrame(c) - } - default: - c.Logger.Warn("unexpected frame", "unexpected_frame_type", frameType.String()) + // observe datatags backflow. + if err := s.handleBackflowFrame(c); err != nil { + c.CloseWithError(fmt.Sprintf("handle backflow err: %v", err)) + return } - return nil } -func (s *Server) handleDataFrame(c *Context) error { - dataFrame := c.Frame.(*frame.DataFrame) +func (s *Server) routingDataFrame(c *Context) error { + dataFrame := c.Frame data_length := len(dataFrame.Payload) // counter +1 @@ -392,7 +377,7 @@ func (s *Server) handleDataFrame(c *Context) error { } func (s *Server) handleBackflowFrame(c *Context) error { - dataFrame := c.Frame.(*frame.DataFrame) + dataFrame := c.Frame sourceID := GetSourceIDFromMetadata(c.FrameMetadata) // write to source with BackflowFrame @@ -400,14 +385,14 @@ func (s *Server) handleBackflowFrame(c *Context) error { Tag: dataFrame.Tag, Carriage: dataFrame.Payload, } - sourceStreams, err := s.connector.Find(sourceIDTagFindConnectionFunc(sourceID, dataFrame.Tag)) + sources, err := s.connector.Find(sourceIDTagFindConnectionFunc(sourceID, dataFrame.Tag)) if err != nil { return err } - for _, source := range sourceStreams { - if source != nil { + for _, s := range sources { + if s != nil { c.Logger.Info("backflow to source", "source_conn_id", sourceID) - if err := source.WriteFrame(bf); err != nil { + if err := s.WriteFrame(bf); err != nil { c.Logger.Error("failed to write frame for backflow to the source", "err", err) return err } @@ -446,8 +431,8 @@ func (s *Server) Downstreams() map[string]string { defer s.mu.Unlock() snapshotOfDownstream := make(map[string]string, len(s.downstreams)) - for addr, client := range s.downstreams { - snapshotOfDownstream[addr] = client.ID() + for _, client := range s.downstreams { + snapshotOfDownstream[client.LocalName()] = client.ID() } return snapshotOfDownstream } @@ -469,18 +454,18 @@ func (s *Server) AddDownstreamServer(c Downstream) { } // dispatch every DataFrames to all downstreams -func (s *Server) dispatchToDownstreams(c *Context) { - dataFrame := c.Frame.(*frame.DataFrame) +func (s *Server) dispatchToDownstreams(c *Context) error { + dataFrame := c.Frame if c.Connection.ClientType() == ClientTypeUpstreamZipper { c.Logger.Debug("ignored client", "client_type", c.Connection.ClientType().String()) // loop protection - return + return nil } mdBytes, err := c.FrameMetadata.Encode() if err != nil { c.Logger.Error("failed to dispatch to downstream", "err", err) - return + return err } dataFrame.Metadata = mdBytes @@ -492,6 +477,8 @@ func (s *Server) dispatchToDownstreams(c *Context) { _ = ds.WriteFrame(dataFrame) } + + return nil } func (s *Server) validateRouter() error { @@ -501,27 +488,6 @@ func (s *Server) validateRouter() error { return nil } -// SetStartHandlers sets a function for operating connection, -// this function executes after handshake successful. -func (s *Server) SetStartHandlers(handlers ...FrameHandler) { - s.startHandlers = append(s.startHandlers, handlers...) -} - -// SetBeforeHandlers set the before handlers of server. -func (s *Server) SetBeforeHandlers(handlers ...FrameHandler) { - s.beforeHandlers = append(s.beforeHandlers, handlers...) -} - -// SetAfterHandlers set the after handlers of server. -func (s *Server) SetAfterHandlers(handlers ...FrameHandler) { - s.afterHandlers = append(s.afterHandlers, handlers...) -} - -// SetConnectionCloseHandlers set the connection close handlers of server. -func (s *Server) SetConnectionCloseHandlers(handlers ...ConnectionHandler) { - s.connectionCloseHandlers = append(s.connectionCloseHandlers, handlers...) -} - func (s *Server) authNames() []string { if len(s.opts.auths) == 0 { return []string{"none"} @@ -546,3 +512,17 @@ func (s *Server) TracerProvider() oteltrace.TracerProvider { } return s.tracerProvider } + +func composeFrameHandler(handler FrameHandler, middlewares ...FrameMiddleware) FrameHandler { + for i := len(middlewares) - 1; i >= 0; i-- { + handler = middlewares[i](handler) + } + return handler +} + +func composeConnHandler(handler ConnHandler, middlewares ...ConnMiddleware) ConnHandler { + for i := len(middlewares) - 1; i >= 0; i-- { + handler = middlewares[i](handler) + } + return handler +} diff --git a/core/server_options.go b/core/server_options.go index 18d565f27..2cdc6b46f 100644 --- a/core/server_options.go +++ b/core/server_options.go @@ -29,11 +29,13 @@ type ServerOption func(*serverOptions) // serverOptions are the options for YoMo server. type serverOptions struct { - quicConfig *quic.Config - tlsConfig *tls.Config - auths map[string]auth.Authentication - logger *slog.Logger - tracerProvider oteltrace.TracerProvider + quicConfig *quic.Config + tlsConfig *tls.Config + auths map[string]auth.Authentication + logger *slog.Logger + tracerProvider oteltrace.TracerProvider + connMiddlewares []ConnMiddleware + frameMiddlewares []FrameMiddleware } func defaultServerOptions() *serverOptions { @@ -88,3 +90,17 @@ func WithServerTracerProvider(tp oteltrace.TracerProvider) ServerOption { o.tracerProvider = tp } } + +// WithFrameMiddleware sets frame middleware for the client. +func WithFrameMiddleware(mws ...FrameMiddleware) ServerOption { + return func(o *serverOptions) { + o.frameMiddlewares = append(o.frameMiddlewares, mws...) + } +} + +// WithConnMiddleware sets conn middleware for the client. +func WithConnMiddleware(mws ...ConnMiddleware) ServerOption { + return func(o *serverOptions) { + o.connMiddlewares = append(o.connMiddlewares, mws...) + } +} diff --git a/options.go b/options.go index f419ef693..7787a6059 100644 --- a/options.go +++ b/options.go @@ -110,4 +110,18 @@ var ( o.serverOption = append(o.serverOption, core.WithServerTracerProvider(tp)) } } + + // WithConnMiddleware sets conn middleware for the zipper. + WithZipperConnMiddleware = func(mw ...core.ConnMiddleware) ZipperOption { + return func(o *zipperOptions) { + o.serverOption = append(o.serverOption, core.WithConnMiddleware(mw...)) + } + } + + // WithFrameMiddleware sets frame middleware for the zipper. + WithZipperFrameMiddleware = func(mw ...core.FrameMiddleware) ZipperOption { + return func(o *zipperOptions) { + o.serverOption = append(o.serverOption, core.WithFrameMiddleware(mw...)) + } + } ) diff --git a/zipper.go b/zipper.go index 3b3cfd3c8..e2212cc15 100644 --- a/zipper.go +++ b/zipper.go @@ -66,14 +66,12 @@ func NewZipper(name string, meshConfig map[string]config.Downstream, options ... for downstreamName, meshConf := range meshConfig { addr := fmt.Sprintf("%s:%d", meshConf.Host, meshConf.Port) - dsLogger := server.Logger().With("downstream_name", downstreamName, "downstream_addr", addr) - clientOptions := append( opts.clientOption, core.WithCredential(meshConf.Credential), core.WithNonBlockWrite(), core.WithConnectUntilSucceed(), - core.WithLogger(dsLogger), + core.WithLogger(server.Logger().With("downstream_name", downstreamName, "downstream_addr", addr)), ) downstream := &downstream{ From 94fdcc0b6230635f6bfd52af9cf151433f383cc4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:31:47 +0000 Subject: [PATCH 07/12] chore(deps): bump google.golang.org/grpc from 1.58.2 to 1.58.3 in /example/2-iopipe (#656) --- example/2-iopipe/go.mod | 2 +- example/2-iopipe/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/2-iopipe/go.mod b/example/2-iopipe/go.mod index dc7770a95..cd5da5671 100644 --- a/example/2-iopipe/go.mod +++ b/example/2-iopipe/go.mod @@ -39,7 +39,7 @@ require ( golang.org/x/tools v0.14.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect - google.golang.org/grpc v1.58.2 // indirect + google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/example/2-iopipe/go.sum b/example/2-iopipe/go.sum index c9c8e0cef..ab9e0aeba 100644 --- a/example/2-iopipe/go.sum +++ b/example/2-iopipe/go.sum @@ -83,8 +83,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1: google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= -google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= -google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From f3b50c661704454c928c5b4e74957d0fd32ff66b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:33:04 +0000 Subject: [PATCH 08/12] chore(deps): bump github.com/vmihailenco/msgpack/v5 from 5.4.0 to 5.4.1 (#662) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 58c5c5e19..a45387e3e 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/spf13/viper v1.17.0 github.com/stretchr/testify v1.8.4 github.com/tetratelabs/wazero v1.5.0 - github.com/vmihailenco/msgpack/v5 v5.4.0 + github.com/vmihailenco/msgpack/v5 v5.4.1 github.com/yomorun/y3 v1.0.5 go.opentelemetry.io/otel v1.19.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 diff --git a/go.sum b/go.sum index 0eb6a6981..574e39415 100644 --- a/go.sum +++ b/go.sum @@ -239,8 +239,8 @@ github.com/teivah/onecontext v1.3.0 h1:tbikMhAlo6VhAuEGCvhc8HlTnpX4xTNPTOseWuhO1 github.com/teivah/onecontext v1.3.0/go.mod h1:hoW1nmdPVK/0jrvGtcx8sCKYs2PiS4z0zzfdeuEVyb0= github.com/tetratelabs/wazero v1.5.0 h1:Yz3fZHivfDiZFUXnWMPUoiW7s8tC1sjdBtlJn08qYa0= github.com/tetratelabs/wazero v1.5.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= -github.com/vmihailenco/msgpack/v5 v5.4.0 h1:hRM0digJwyR6vll33NNAwCFguy5JuBD6jxDmQP3l608= -github.com/vmihailenco/msgpack/v5 v5.4.0/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yomorun/y3 v1.0.5 h1:1qoZrDX+47hgU2pVJgoCEpeeXEOqml/do5oHjF9Wef4= From caac7d729cfd369639373a14cc46dc8e2f1e71f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:34:22 +0000 Subject: [PATCH 09/12] chore(deps): bump google.golang.org/grpc from 1.58.2 to 1.58.3 in /example/1-pipeline (#657) --- example/1-pipeline/go.mod | 2 +- example/1-pipeline/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/1-pipeline/go.mod b/example/1-pipeline/go.mod index 9fa213196..51f3d41cd 100644 --- a/example/1-pipeline/go.mod +++ b/example/1-pipeline/go.mod @@ -39,7 +39,7 @@ require ( golang.org/x/tools v0.14.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect - google.golang.org/grpc v1.58.2 // indirect + google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/example/1-pipeline/go.sum b/example/1-pipeline/go.sum index c9c8e0cef..ab9e0aeba 100644 --- a/example/1-pipeline/go.sum +++ b/example/1-pipeline/go.sum @@ -83,8 +83,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1: google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= -google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= -google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 169d7d8de299d928f2238ae96a931af7ab58f77c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 10:38:18 +0800 Subject: [PATCH 10/12] chore(deps): bump google.golang.org/grpc from 1.58.2 to 1.58.3 (#659) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a45387e3e..0ebd8df22 100644 --- a/go.mod +++ b/go.mod @@ -74,7 +74,7 @@ require ( golang.org/x/text v0.13.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect - google.golang.org/grpc v1.58.2 // indirect + google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/go.sum b/go.sum index 574e39415..ecd7f480c 100644 --- a/go.sum +++ b/go.sum @@ -578,8 +578,8 @@ google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= -google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= 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= From a06576f01faa3760bbe353a37953c405fc9488ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:38:48 +0000 Subject: [PATCH 11/12] chore(deps): bump google.golang.org/grpc from 1.58.2 to 1.58.3 in /example/9-cli/source (#658) --- example/9-cli/source/go.mod | 2 +- example/9-cli/source/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/example/9-cli/source/go.mod b/example/9-cli/source/go.mod index be452d1e1..292be148f 100644 --- a/example/9-cli/source/go.mod +++ b/example/9-cli/source/go.mod @@ -39,7 +39,7 @@ require ( golang.org/x/tools v0.14.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect - google.golang.org/grpc v1.58.2 // indirect + google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/example/9-cli/source/go.sum b/example/9-cli/source/go.sum index c9c8e0cef..ab9e0aeba 100644 --- a/example/9-cli/source/go.sum +++ b/example/9-cli/source/go.sum @@ -83,8 +83,8 @@ google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1: google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= -google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= -google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From a0047c828101f7ab5586873d7339a4ec62546d6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 02:43:18 +0000 Subject: [PATCH 12/12] chore(deps): bump github.com/quic-go/quic-go from 0.39.0 to 0.39.3 (#661) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0ebd8df22..704a0d811 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/fatih/color v1.15.0 github.com/joho/godotenv v1.5.1 github.com/matoous/go-nanoid/v2 v2.0.0 - github.com/quic-go/quic-go v0.39.0 + github.com/quic-go/quic-go v0.39.3 github.com/reactivex/rxgo/v2 v2.5.0 github.com/second-state/WasmEdge-go v0.13.4 github.com/spf13/cobra v1.7.0 diff --git a/go.sum b/go.sum index ecd7f480c..e4698b960 100644 --- a/go.sum +++ b/go.sum @@ -192,8 +192,8 @@ github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.39.0 h1:AgP40iThFMY0bj8jGxROhw3S0FMGa8ryqsmi9tBH3So= -github.com/quic-go/quic-go v0.39.0/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= +github.com/quic-go/quic-go v0.39.3 h1:o3YB6t2SR+HU/pgwF29kJ6g4jJIJEwEZ8CKia1h1TKg= +github.com/quic-go/quic-go v0.39.3/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= github.com/reactivex/rxgo/v2 v2.5.0 h1:FhPgHwX9vKdNQB2gq9EPt+EKk9QrrzoeztGbEEnZam4= github.com/reactivex/rxgo/v2 v2.5.0/go.mod h1:bs4fVZxcb5ZckLIOeIeVH942yunJLWDABWGbrHAW+qU= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=