diff --git a/go.mod b/go.mod index 8bc80aeac..e41494993 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,13 @@ module github.com/networkservicemesh/sdk go 1.15 require ( + github.com/HdrHistogram/hdrhistogram-go v0.9.0 // indirect github.com/RoaringBitmap/roaring v0.4.23 - github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect + github.com/codahale/hdrhistogram v0.9.0 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/edwarnicke/exechelper v1.0.1 github.com/edwarnicke/grpcfd v0.0.0-20200920223154-d5b6e1f19bd0 - github.com/edwarnicke/serialize v1.0.0 + github.com/edwarnicke/serialize v1.0.2-0.20201017171944-cf1114ca2f6f github.com/fsnotify/fsnotify v1.4.7 github.com/ghodss/yaml v1.0.0 github.com/golang/protobuf v1.4.2 @@ -24,13 +25,11 @@ require ( github.com/spiffe/go-spiffe/v2 v2.0.0-alpha.4.0.20200528145730-dc11d0c74e85 github.com/stretchr/testify v1.5.1 github.com/uber/jaeger-client-go v2.21.1+incompatible - github.com/uber/jaeger-lib v2.2.0+incompatible // indirect + github.com/uber/jaeger-lib v2.4.0+incompatible // indirect go.uber.org/atomic v1.7.0 // indirect - go.uber.org/goleak v1.0.1-0.20200717213025-100c34bdc9d6 - golang.org/x/net v0.0.0-20201010224723-4f7140c49acb // indirect + go.uber.org/goleak v1.1.10 golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc gonum.org/v1/gonum v0.6.2 - google.golang.org/genproto v0.0.0-20201014134559-03b6142f0dc9 // indirect google.golang.org/grpc v1.32.0 google.golang.org/protobuf v1.25.0 ) diff --git a/go.sum b/go.sum index 40df893c3..58c786c3c 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/HdrHistogram/hdrhistogram-go v0.9.0 h1:dpujRju0R4M/QZzcnR1LH1qm+TVG3UzkWdp5tH1WMcg= +github.com/HdrHistogram/hdrhistogram-go v0.9.0/go.mod h1:nxrse8/Tzg2tg3DZcZjm6qEclQKK70g0KxO61gFFZD4= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/OneOfOne/xxhash v1.2.3 h1:wS8NNaIgtzapuArKIAjsyXtEN/IUjQkbw90xszUdS40= github.com/OneOfOne/xxhash v1.2.3/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -19,8 +21,8 @@ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6D github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w= -github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= +github.com/codahale/hdrhistogram v0.9.0 h1:9GjrtRI+mLEFPtTfR/AZhcxp+Ii8NZYWq5104FbZQY0= +github.com/codahale/hdrhistogram v0.9.0/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= 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= @@ -32,8 +34,8 @@ github.com/edwarnicke/grpcfd v0.0.0-20200920223154-d5b6e1f19bd0 h1:FHjcIM6YU8DnC github.com/edwarnicke/grpcfd v0.0.0-20200920223154-d5b6e1f19bd0/go.mod h1:rHihB9YvNMixz8rS+ZbwosI2kj65VLkeyYAI2M+/cGA= github.com/edwarnicke/serialize v0.0.0-20200705214914-ebc43080eecf h1:/lViRfaDxKINb2X6kOR3EJKJGR+MxUvqfgtYt5nh+qc= github.com/edwarnicke/serialize v0.0.0-20200705214914-ebc43080eecf/go.mod h1:XvbCO/QGsl3X8RzjBMoRpkm54FIAZH5ChK2j+aox7pw= -github.com/edwarnicke/serialize v1.0.0 h1:vPl+qxXwI3RqXZeaZwrAW56dzZwe5rsXuUpRabxaIsM= -github.com/edwarnicke/serialize v1.0.0/go.mod h1:XvbCO/QGsl3X8RzjBMoRpkm54FIAZH5ChK2j+aox7pw= +github.com/edwarnicke/serialize v1.0.2-0.20201017171944-cf1114ca2f6f h1:7pWVVIVMlL8pvc6jonUWcPcWKqPn5Vb2wX5gGyLdbtM= +github.com/edwarnicke/serialize v1.0.2-0.20201017171944-cf1114ca2f6f/go.mod h1:bJ8sBYQExvfyOBt41jVY2soYHCe6q1O1siZDhyjp/CQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -194,8 +196,8 @@ github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDW github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/uber/jaeger-client-go v2.21.1+incompatible h1:oozboeZmWz+tyh3VZttJWlF3K73mHgbokieceqKccLo= github.com/uber/jaeger-client-go v2.21.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= -github.com/uber/jaeger-lib v2.2.0+incompatible h1:MxZXOiR2JuoANZ3J6DE/U0kSFv/eJ/GfSYVCjK7dyaw= -github.com/uber/jaeger-lib v2.2.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= +github.com/uber/jaeger-lib v2.4.0+incompatible h1:fY7QsGQWiCt8pajv4r7JEvmATdCVaWxXbjwyYwsNaLQ= +github.com/uber/jaeger-lib v2.4.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b h1:vVRagRXf67ESqAb72hG2C/ZwI8NtJF2u2V76EsuOHGY= @@ -206,14 +208,12 @@ go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.0.1-0.20200717213025-100c34bdc9d6 h1:+os4Rcinl2P8NEQXzKVaoDAkLtTbWHOCKLvGMR0nnWs= -go.uber.org/goleak v1.0.1-0.20200717213025-100c34bdc9d6/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= +go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a h1:aczoJ0HPNE92XKa7DrIzkNN6esOKO2TBwiiYoKcINhA= golang.org/x/crypto v0.0.0-20200206161412-a0c6ece9d31a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -235,8 +235,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -250,16 +248,12 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190523142557-0e01d883c5c5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc h1:HVFDs9bKvTxP6bh1Rj9MCSo+UmafQtI8ZWDPVwVk9g4= golang.org/x/sys v0.0.0-20201014080544-cc95f250f6bc/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -285,8 +279,6 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20201014134559-03b6142f0dc9 h1:fG84H9C3EXfuDlzkG+VEPDYHHExklP6scH1QZ5gQTqU= -google.golang.org/genproto v0.0.0-20201014134559-03b6142f0dc9/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= @@ -304,7 +296,6 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/networkservice/chains/nsmgr/peertracker/server.go b/pkg/networkservice/chains/nsmgr/peertracker/server.go index f34a1d53c..3dc6e94ff 100644 --- a/pkg/networkservice/chains/nsmgr/peertracker/server.go +++ b/pkg/networkservice/chains/nsmgr/peertracker/server.go @@ -26,8 +26,9 @@ import ( "github.com/networkservicemesh/api/pkg/api/networkservice" "google.golang.org/grpc/peer" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/networkservice/chains/nsmgr" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" ) const ( diff --git a/pkg/networkservice/common/heal/client.go b/pkg/networkservice/common/heal/client.go index 70460b680..13ee7f4e6 100644 --- a/pkg/networkservice/common/heal/client.go +++ b/pkg/networkservice/common/heal/client.go @@ -28,7 +28,7 @@ import ( "github.com/networkservicemesh/api/pkg/api/networkservice" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" + "github.com/edwarnicke/serialize" "github.com/networkservicemesh/sdk/pkg/tools/addressof" diff --git a/pkg/networkservice/common/monitor/server.go b/pkg/networkservice/common/monitor/server.go index 874a75051..a1106b2e8 100644 --- a/pkg/networkservice/common/monitor/server.go +++ b/pkg/networkservice/common/monitor/server.go @@ -23,9 +23,10 @@ import ( "github.com/golang/protobuf/ptypes/empty" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" "github.com/networkservicemesh/sdk/pkg/networkservice/core/trace" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" "github.com/networkservicemesh/api/pkg/api/networkservice" ) diff --git a/pkg/networkservice/common/refresh/client.go b/pkg/networkservice/common/refresh/client.go index ec03ceb6f..7a3977c54 100644 --- a/pkg/networkservice/common/refresh/client.go +++ b/pkg/networkservice/common/refresh/client.go @@ -27,10 +27,11 @@ import ( "github.com/networkservicemesh/api/pkg/api/networkservice" "google.golang.org/grpc" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" "github.com/networkservicemesh/sdk/pkg/networkservice/core/trace" "github.com/networkservicemesh/sdk/pkg/tools/extend" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" ) type refreshClient struct { diff --git a/pkg/networkservice/common/timeout/server.go b/pkg/networkservice/common/timeout/server.go index 70bfb975f..b366d137f 100644 --- a/pkg/networkservice/common/timeout/server.go +++ b/pkg/networkservice/common/timeout/server.go @@ -25,10 +25,11 @@ import ( "github.com/golang/protobuf/ptypes/empty" "github.com/networkservicemesh/api/pkg/api/networkservice" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" "github.com/networkservicemesh/sdk/pkg/networkservice/core/trace" "github.com/networkservicemesh/sdk/pkg/tools/extend" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" ) type timeoutServer struct { @@ -49,7 +50,6 @@ type timeoutServer struct { func NewServer(onTimout *networkservice.NetworkServiceServer) networkservice.NetworkServiceServer { rv := &timeoutServer{ connections: make(map[string]*time.Timer), - executor: serialize.NewExecutor(), onTimeout: onTimout, } if rv.onTimeout == nil { diff --git a/pkg/networkservice/connectioncontext/dnscontext/client.go b/pkg/networkservice/connectioncontext/dnscontext/client.go index 40dd9a427..5824adac2 100644 --- a/pkg/networkservice/connectioncontext/dnscontext/client.go +++ b/pkg/networkservice/connectioncontext/dnscontext/client.go @@ -26,9 +26,10 @@ import ( "github.com/sirupsen/logrus" "google.golang.org/grpc" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" "github.com/networkservicemesh/sdk/pkg/tools/dnscontext" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" ) type dnsContextClient struct { diff --git a/pkg/networkservice/core/eventchannel/monitor_client.go b/pkg/networkservice/core/eventchannel/monitor_client.go index 08956d43f..03bbdfa09 100644 --- a/pkg/networkservice/core/eventchannel/monitor_client.go +++ b/pkg/networkservice/core/eventchannel/monitor_client.go @@ -28,7 +28,7 @@ import ( "github.com/networkservicemesh/api/pkg/api/networkservice" "google.golang.org/grpc" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" + "github.com/edwarnicke/serialize" ) type monitorConnectionClient struct { diff --git a/pkg/networkservice/core/eventchannel/monitor_server.go b/pkg/networkservice/core/eventchannel/monitor_server.go index b4f9c28e7..ef0b4ecb3 100644 --- a/pkg/networkservice/core/eventchannel/monitor_server.go +++ b/pkg/networkservice/core/eventchannel/monitor_server.go @@ -23,7 +23,7 @@ import ( "github.com/networkservicemesh/api/pkg/api/networkservice" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" + "github.com/edwarnicke/serialize" ) type monitorConnectionServer struct { diff --git a/pkg/networkservice/utils/inject/injectpeer/client.go b/pkg/networkservice/utils/inject/injectpeer/client.go index 78d3ce1e9..058a505eb 100644 --- a/pkg/networkservice/utils/inject/injectpeer/client.go +++ b/pkg/networkservice/utils/inject/injectpeer/client.go @@ -36,8 +36,9 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/peer" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/networkservice/core/next" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" ) type injectPeerClient struct { diff --git a/pkg/registry/memory/ns_server.go b/pkg/registry/memory/ns_server.go index 7822db03e..8b2fe97cb 100644 --- a/pkg/registry/memory/ns_server.go +++ b/pkg/registry/memory/ns_server.go @@ -25,9 +25,10 @@ import ( "github.com/google/uuid" "github.com/networkservicemesh/api/pkg/api/registry" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/registry/core/next" "github.com/networkservicemesh/sdk/pkg/tools/matchutils" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" ) type networkServiceRegistryServer struct { diff --git a/pkg/registry/memory/nse_server.go b/pkg/registry/memory/nse_server.go index ab40c968e..40694d770 100644 --- a/pkg/registry/memory/nse_server.go +++ b/pkg/registry/memory/nse_server.go @@ -28,9 +28,10 @@ import ( "github.com/golang/protobuf/ptypes/empty" "github.com/networkservicemesh/api/pkg/api/registry" + "github.com/edwarnicke/serialize" + "github.com/networkservicemesh/sdk/pkg/registry/core/next" "github.com/networkservicemesh/sdk/pkg/tools/matchutils" - "github.com/networkservicemesh/sdk/pkg/tools/serialize" ) type networkServiceEndpointRegistryServer struct { diff --git a/pkg/tools/serialize/README.md b/pkg/tools/serialize/README.md deleted file mode 100644 index c06dd0e35..000000000 --- a/pkg/tools/serialize/README.md +++ /dev/null @@ -1,62 +0,0 @@ -## Intro - -There are lots of instances in which you want to insure that a series of executions have the properties of: - -1. Exclusivity: One at a time execution -2. Order: Execution happens in first in, first out (FIFO) order - -serial.Executor provides these guarantees. Given a serialize.Executor ```executor```: - -```go -executor.AsyncExec(func(){...}) -``` - -will non-blockingly add ```func(){...}``` to an ordered queue (first in, first out (FIFO)) to be executed. - -```executor.AsyncExec(func(){...}``` returns a channel that will be closed when func() has returned. Therefore: - -```go -<-executor.AsyncExec(func(){...}) -``` - -will add ```func(){...}``` to an ordered queue (first in, first out (FIFO)) to be executed and return when -```func(){...}``` has returned. - -### Comparison to sync.Mutex - -```sync.Mutex``` guarantees exclusivity, but not order. For this reason it is often used synchronously to insure ordering. -```serialize.Executor``` guarantees both exclusivity and order, allowing asynchronous use. - -## Uses - -serial.Executor.Exec can be used in situations in which you need thread safe modification of -an object but don't need to or want to block waiting for it to happen: - -```go -type myStruct struct { - data string - executor serialize.Executor -} - -func (m *myStruct) Update(s string) { - m.executor.AsyncExec(func(){ - m.data = s - }) -} -``` - -serialize.Executor.Exec can also be in situations in which you need thread safe modification of -an object but need Synchronous update. - -```go -type myStruct struct { - data string - executor serialize.Executor -} - -func (m *myStruct) Update(s string) { - <-m.executor.AsyncExec(func(){ - m.data = s - }) -} -``` diff --git a/pkg/tools/serialize/serialize.go b/pkg/tools/serialize/serialize.go deleted file mode 100644 index 8dc6ec5be..000000000 --- a/pkg/tools/serialize/serialize.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) 2020 Cisco Systems, Inc. -// -// SPDX-License-Identifier: Apache-2.0 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package serialize provides a simple means for Async or Sync execution of a func() -// with the guarantee that each func() will be executed exactly once and that all funcs() -// will be executed in order -package serialize - -import ( - "sync" - "sync/atomic" -) - -const ( - channelSize = 100 -) - -// Executor - a struct that can be used to guarantee exclusive, in order execution of functions. -type Executor struct { - execCh chan func() - init sync.Once - count int32 -} - -// NewExecutor - provides a new Executor -// Deprecated: Please just used Executor{} in the future. The zero value of Executor works just fine. -func NewExecutor() Executor { - return Executor{} -} - -// AsyncExec - guarantees f() will be executed Exclusively and in the Order submitted. -// It immediately returns a channel that will be closed when f() has completed execution. -func (e *Executor) AsyncExec(f func()) <-chan struct{} { - // Initialize *once* - e.init.Do(func() { - e.execCh = make(chan func(), channelSize) - }) - // Start go routine if we don't have one - if atomic.AddInt32(&e.count, 1) == 1 { - go func() { - for g := range e.execCh { - g() - if atomic.AddInt32(&e.count, -1) == 0 { - return - } - } - }() - } - done := make(chan struct{}) - e.execCh <- func() { - f() - close(done) - } - return done -} diff --git a/pkg/tools/serialize/serialize_test.go b/pkg/tools/serialize/serialize_test.go deleted file mode 100644 index 08fcd6983..000000000 --- a/pkg/tools/serialize/serialize_test.go +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) 2020 Cisco and/or its affiliates. -// -// SPDX-License-Identifier: Apache-2.0 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package serialize_test tests the contracts of the serialize.Executor which are: -// 1. One at a time - the executor will never execute more than one func() -// provided to it at a time -// 2. In Order - the order of execution of func()s provided to it will always be preserved: first in, first executed -package serialize_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/networkservicemesh/sdk/pkg/tools/serialize" -) - -func TestASyncExec(t *testing.T) { - exec := serialize.NewExecutor() - count := 0 - completion0 := make(chan struct{}) - exec.AsyncExec(func() { - assert.Equal(t, count, 0) - count = 1 - close(completion0) - }) - select { - case <-completion0: - assert.Fail(t, "exec.AsyncExec did run to completion before returning.") - default: - } -} - -func TestSyncExec(t *testing.T) { - var exec serialize.Executor - count := 0 - completion0 := make(chan struct{}) - <-exec.AsyncExec(func() { - assert.Equal(t, count, 0) - count = 1 - close(completion0) - }) - select { - case <-completion0: - default: - assert.Fail(t, "exec.SyncExec did not run to completion before returning.") - } -} - -func TestExecOrder1(t *testing.T) { - var exec serialize.Executor - count := 0 - trigger0 := make(chan struct{}) - completion0 := make(chan struct{}) - exec.AsyncExec(func() { - <-trigger0 - assert.Equal(t, count, 0) - count = 1 - close(completion0) - }) - trigger1 := make(chan struct{}) - completion1 := make(chan struct{}) - exec.AsyncExec(func() { - <-trigger1 - assert.Equal(t, count, 1) - count = 2 - close(completion1) - }) - // Let the second one start first - close(trigger1) - close(trigger0) - <-completion0 - <-completion1 -} - -// Same as TestExecOrder1 but making sure out of order fails as expected -func TestExecOrder2(t *testing.T) { - var exec serialize.Executor - count := 0 - - trigger1 := make(chan struct{}) - completion1 := make(chan struct{}) - exec.AsyncExec(func() { - <-trigger1 - assert.NotEqual(t, count, 1) - count = 2 - close(completion1) - }) - - trigger0 := make(chan struct{}) - completion0 := make(chan struct{}) - exec.AsyncExec(func() { - <-trigger0 - assert.NotEqual(t, count, 0) - count = 1 - close(completion0) - }) - // Let the second one start first - close(trigger1) - close(trigger0) - <-completion0 - <-completion1 -} - -func TestExecOneAtATime(t *testing.T) { - var exec serialize.Executor - start := make(chan struct{}) - count := 100 - finished := make([]chan struct{}, count) - var running int - for i := 0; i < count; i++ { - finished[i] = make(chan struct{}) - end := finished[i] - exec.AsyncExec(func() { - <-start - assert.Equal(t, running, 0) - running++ - assert.Equal(t, running, 1) - running-- - close(end) - }) - } - close(start) - for _, done := range finished { - <-done - } -} - -func BenchmarkExecutorAsync(b *testing.B) { - var exec serialize.Executor - for i := 0; i < b.N-1; i++ { - exec.AsyncExec(func() {}) - } - <-exec.AsyncExec(func() {}) -} - -func BenchmarkExecutorSync(b *testing.B) { - var exec serialize.Executor - for i := 0; i < b.N; i++ { - <-exec.AsyncExec(func() {}) - } -}