diff --git a/CHANGES.txt b/CHANGES.txt index 1646ab1f..c6a00fa7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,8 @@ +5.4.0 (July 18, 2023) +- Improved streaming architecture implementation to apply feature flag updates from the notification received which is now enhanced, improving efficiency and reliability of the whole update system. +- Fixed possible edge case issue where deleting a feature flag doesn’t propagate immediately. +- Updated docker images for vulnerability fixes. + 5.3.2 (June 21, 2023) - Updated dependency of gin to v1.9.1 for vulnerability fixes. - Updated docker images for vulnerability fixes. diff --git a/docker/Dockerfile.proxy b/docker/Dockerfile.proxy index 75da07f7..e2ea204a 100644 --- a/docker/Dockerfile.proxy +++ b/docker/Dockerfile.proxy @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.20.5-alpine3.18 AS builder +FROM golang:1.20.6-alpine3.18 AS builder ARG EXTRA_BUILD_ARGS diff --git a/docker/Dockerfile.synchronizer b/docker/Dockerfile.synchronizer index e0dfc17b..4d10cc1f 100644 --- a/docker/Dockerfile.synchronizer +++ b/docker/Dockerfile.synchronizer @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.20.5-alpine3.18 AS builder +FROM golang:1.20.6-alpine3.18 AS builder ARG EXTRA_BUILD_ARGS diff --git a/go.mod b/go.mod index c2066d1f..908d8a86 100644 --- a/go.mod +++ b/go.mod @@ -7,8 +7,8 @@ require ( github.com/gin-contrib/gzip v0.0.6 github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.3.0 - github.com/splitio/gincache v0.0.1-rc7 - github.com/splitio/go-split-commons/v4 v4.3.3 + github.com/splitio/gincache v1.0.1 + github.com/splitio/go-split-commons/v5 v5.0.0 github.com/splitio/go-toolkit/v5 v5.3.1 go.etcd.io/bbolt v1.3.6 ) @@ -40,6 +40,7 @@ require ( golang.org/x/arch v0.3.0 // indirect golang.org/x/crypto v0.9.0 // indirect golang.org/x/net v0.10.0 // indirect + golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect google.golang.org/protobuf v1.30.0 // indirect diff --git a/go.sum b/go.sum index 32598afa..bbe5b69d 100644 --- a/go.sum +++ b/go.sum @@ -22,35 +22,27 @@ github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= -github.com/gin-contrib/gzip v0.0.3/go.mod h1:YxxswVZIqOvcHEQpsSn+QF5guQtO1dCfy0shBPy4jFc= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/gin-gonic/gin v1.7.2/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= @@ -58,7 +50,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -72,18 +63,15 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= @@ -97,17 +85,16 @@ github.com/redis/go-redis/v9 v9.0.4/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDO github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= -github.com/splitio/gincache v0.0.1-rc7 h1:BNIP3uaT4zqRepYwi6TRJevzPX3EsgUnLSA3nwNu5tw= -github.com/splitio/gincache v0.0.1-rc7/go.mod h1:IUKPDIlTSH8bNqpgMDWjgrbbkqhApnQHSxXp5uKjGg8= -github.com/splitio/go-split-commons/v4 v4.3.3 h1:9L8Q+0hW2LEmWOuTeiWik3OgQfI4LvK32AFnKifvFhA= -github.com/splitio/go-split-commons/v4 v4.3.3/go.mod h1:hj+ota77quCRuyK1cK8EOZANGDIlwCMBosF27I158S8= +github.com/splitio/gincache v1.0.1 h1:dLYdANY/BqH4KcUMCe/LluLyV5WtuE/LEdQWRE06IXU= +github.com/splitio/gincache v1.0.1/go.mod h1:CcgJDSM9Af75kyBH0724v55URVwMBuSj5x1eCWIOECY= +github.com/splitio/go-split-commons/v5 v5.0.0 h1:bGRi0cf1JP5VNSi0a4BPQEWv/DACkeSKliazhPMVDPk= +github.com/splitio/go-split-commons/v5 v5.0.0/go.mod h1:lzoVmYJaCqB8UPSxWva0BZe7fF+bRJD+eP0rNi/lL7c= github.com/splitio/go-toolkit/v5 v5.3.1 h1:9J/byd0fRxWj5/Zg0QZOnUxKBDIAMCGr7rySYzJKdJg= github.com/splitio/go-toolkit/v5 v5.3.1/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko= 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/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.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.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -120,9 +107,7 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg= github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= -github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= @@ -131,18 +116,14 @@ go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -153,8 +134,6 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= @@ -171,8 +150,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/splitio/admin/common/config.go b/splitio/admin/common/config.go index e4f742fb..6187c8e0 100644 --- a/splitio/admin/common/config.go +++ b/splitio/admin/common/config.go @@ -1,6 +1,6 @@ package common -import "github.com/splitio/go-split-commons/v4/storage" +import "github.com/splitio/go-split-commons/v5/storage" // Storages wraps storages in one struct type Storages struct { diff --git a/splitio/admin/controllers/helpers.go b/splitio/admin/controllers/helpers.go index 4a90d9c3..d698b5e1 100644 --- a/splitio/admin/controllers/helpers.go +++ b/splitio/admin/controllers/helpers.go @@ -3,8 +3,8 @@ package controllers import ( "time" - "github.com/splitio/go-split-commons/v4/storage" - "github.com/splitio/go-split-commons/v4/telemetry" + "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v5/telemetry" "github.com/splitio/split-synchronizer/v5/splitio/admin/views/dashboard" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" diff --git a/splitio/commitversion.go b/splitio/commitversion.go index 74424b19..47b58123 100644 --- a/splitio/commitversion.go +++ b/splitio/commitversion.go @@ -5,4 +5,4 @@ This file is created automatically, please do not edit */ // CommitVersion is the version of the last commit previous to release -const CommitVersion = "4e4300e" +const CommitVersion = "da63b9f" diff --git a/splitio/common/conf/advanced.go b/splitio/common/conf/advanced.go index c36568ae..559257aa 100644 --- a/splitio/common/conf/advanced.go +++ b/splitio/common/conf/advanced.go @@ -3,7 +3,7 @@ package conf import ( "os" - "github.com/splitio/go-split-commons/v4/conf" + "github.com/splitio/go-split-commons/v5/conf" ) // InitAdvancedOptions initializes an advanced config with default values + overriden urls. diff --git a/splitio/common/impressionlistener/listener.go b/splitio/common/impressionlistener/listener.go index 3f06e921..db0880cd 100644 --- a/splitio/common/impressionlistener/listener.go +++ b/splitio/common/impressionlistener/listener.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/struct/traits/lifecycle" ) diff --git a/splitio/common/impressionlistener/listener_test.go b/splitio/common/impressionlistener/listener_test.go index 4e368d05..3a48bd21 100644 --- a/splitio/common/impressionlistener/listener_test.go +++ b/splitio/common/impressionlistener/listener_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" ) func TestImpressionListener(t *testing.T) { diff --git a/splitio/common/impressionlistener/mocks/listener.go b/splitio/common/impressionlistener/mocks/listener.go index d5e01f02..13b0b486 100644 --- a/splitio/common/impressionlistener/mocks/listener.go +++ b/splitio/common/impressionlistener/mocks/listener.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" ) diff --git a/splitio/common/runtime.go b/splitio/common/runtime.go index 4eb3116d..9d0807ee 100644 --- a/splitio/common/runtime.go +++ b/splitio/common/runtime.go @@ -7,7 +7,7 @@ import ( "syscall" "time" - "github.com/splitio/go-split-commons/v4/synchronizer" + "github.com/splitio/go-split-commons/v5/synchronizer" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/sync" diff --git a/splitio/common/sync/sync.go b/splitio/common/sync/sync.go index ae57b849..54f2909e 100644 --- a/splitio/common/sync/sync.go +++ b/splitio/common/sync/sync.go @@ -3,11 +3,10 @@ package sync import ( "github.com/splitio/go-toolkit/v5/logging" - "github.com/splitio/go-split-commons/v4/conf" + "github.com/splitio/go-split-commons/v5/conf" - "github.com/splitio/go-split-commons/v4/healthcheck/application" - "github.com/splitio/go-split-commons/v4/synchronizer" - "github.com/splitio/go-split-commons/v4/tasks" + "github.com/splitio/go-split-commons/v5/synchronizer" + "github.com/splitio/go-split-commons/v5/tasks" ) // WSync is a wrapper for the Regular synchronizer that handles both local telemetry @@ -26,10 +25,9 @@ func NewSynchronizer( logger logging.LoggerInterface, inMememoryFullQueue chan string, userTelemetryTasks []tasks.Task, - appMonitor application.MonitorProducerInterface, ) *WSync { return &WSync{ - Synchronizer: synchronizer.NewSynchronizer(confAdvanced, splitTasks, workers, logger, inMememoryFullQueue, appMonitor), + Synchronizer: synchronizer.NewSynchronizer(confAdvanced, splitTasks, workers, logger, inMememoryFullQueue), logger: logger, userTelemetryTasks: userTelemetryTasks, } diff --git a/splitio/producer/conf/sections.go b/splitio/producer/conf/sections.go index 00e3d7c1..32808ab6 100644 --- a/splitio/producer/conf/sections.go +++ b/splitio/producer/conf/sections.go @@ -1,7 +1,7 @@ package conf import ( - cconf "github.com/splitio/go-split-commons/v4/conf" + cconf "github.com/splitio/go-split-commons/v5/conf" "github.com/splitio/split-synchronizer/v5/splitio/common/conf" ) diff --git a/splitio/producer/initialization.go b/splitio/producer/initialization.go index ad5fdbce..532953b7 100644 --- a/splitio/producer/initialization.go +++ b/splitio/producer/initialization.go @@ -5,19 +5,19 @@ import ( "fmt" "time" - cconf "github.com/splitio/go-split-commons/v4/conf" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/provisional/strategy" - "github.com/splitio/go-split-commons/v4/service/api" - "github.com/splitio/go-split-commons/v4/storage/filter" - "github.com/splitio/go-split-commons/v4/storage/inmemory" - "github.com/splitio/go-split-commons/v4/storage/redis" - "github.com/splitio/go-split-commons/v4/synchronizer" - "github.com/splitio/go-split-commons/v4/synchronizer/worker/impressionscount" - "github.com/splitio/go-split-commons/v4/synchronizer/worker/segment" - "github.com/splitio/go-split-commons/v4/synchronizer/worker/split" - "github.com/splitio/go-split-commons/v4/tasks" - "github.com/splitio/go-split-commons/v4/telemetry" + cconf "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/provisional/strategy" + "github.com/splitio/go-split-commons/v5/service/api" + "github.com/splitio/go-split-commons/v5/storage/filter" + "github.com/splitio/go-split-commons/v5/storage/inmemory" + "github.com/splitio/go-split-commons/v5/storage/redis" + "github.com/splitio/go-split-commons/v5/synchronizer" + "github.com/splitio/go-split-commons/v5/synchronizer/worker/impressionscount" + "github.com/splitio/go-split-commons/v5/synchronizer/worker/segment" + "github.com/splitio/go-split-commons/v5/synchronizer/worker/split" + "github.com/splitio/go-split-commons/v5/tasks" + "github.com/splitio/go-split-commons/v5/telemetry" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/admin" @@ -118,8 +118,8 @@ func Start(logger logging.LoggerInterface, cfg *conf.Main) error { eventEvictionMonitor := evcalc.New(1) workers := synchronizer.Workers{ - SplitFetcher: split.NewSplitFetcher(storages.SplitStorage, splitAPI.SplitFetcher, logger, syncTelemetryStorage, appMonitor), - SegmentFetcher: segment.NewSegmentFetcher(storages.SplitStorage, storages.SegmentStorage, splitAPI.SegmentFetcher, + SplitUpdater: split.NewSplitUpdater(storages.SplitStorage, splitAPI.SplitFetcher, logger, syncTelemetryStorage, appMonitor), + SegmentUpdater: segment.NewSegmentUpdater(storages.SplitStorage, storages.SegmentStorage, splitAPI.SegmentFetcher, logger, syncTelemetryStorage, appMonitor), ImpressionsCountRecorder: impressionscount.NewRecorderSingle(impressionsCounter, splitAPI.ImpressionRecorder, metadata, logger, syncTelemetryStorage), @@ -128,8 +128,8 @@ func Start(logger logging.LoggerInterface, cfg *conf.Main) error { storages.SplitStorage, storages.SegmentStorage, logger, metadata, syncTelemetryStorage), } splitTasks := synchronizer.SplitTasks{ - SplitSyncTask: tasks.NewFetchSplitsTask(workers.SplitFetcher, int(cfg.Sync.SplitRefreshRateMs)/1000, logger), - SegmentSyncTask: tasks.NewFetchSegmentsTask(workers.SegmentFetcher, int(cfg.Sync.SegmentRefreshRateMs)/1000, + SplitSyncTask: tasks.NewFetchSplitsTask(workers.SplitUpdater, int(cfg.Sync.SplitRefreshRateMs)/1000, logger), + SegmentSyncTask: tasks.NewFetchSegmentsTask(workers.SegmentUpdater, int(cfg.Sync.SegmentRefreshRateMs)/1000, advanced.SegmentWorkers, advanced.SegmentQueueSize, logger), ImpressionsCountSyncTask: tasks.NewRecordImpressionsCountTask(workers.ImpressionsCountRecorder, logger, impressionsCountPeriodTaskInMemory), @@ -246,7 +246,7 @@ func Start(logger logging.LoggerInterface, cfg *conf.Main) error { sdkTelemetryWorker := worker.NewTelemetryMultiWorker(logger, sdkTelemetryStorage, splitAPI.TelemetryRecorder) sdkTelemetryTask := task.NewTelemetrySyncTask(sdkTelemetryWorker, logger, int(cfg.Sync.Advanced.TelemetryPushRateMs/1000)) - syncImpl := ssync.NewSynchronizer(*advanced, splitTasks, workers, logger, nil, []tasks.Task{sdkTelemetryTask}, appMonitor) + syncImpl := ssync.NewSynchronizer(*advanced, splitTasks, workers, logger, nil, []tasks.Task{sdkTelemetryTask}) managerStatus := make(chan int, 1) syncManager, err := synchronizer.NewSynchronizerManager( syncImpl, diff --git a/splitio/producer/initialization_test.go b/splitio/producer/initialization_test.go index 9a0c5316..d03c6e22 100644 --- a/splitio/producer/initialization_test.go +++ b/splitio/producer/initialization_test.go @@ -8,11 +8,11 @@ import ( "os" "testing" - config "github.com/splitio/go-split-commons/v4/conf" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/service" - "github.com/splitio/go-split-commons/v4/service/mocks" - predis "github.com/splitio/go-split-commons/v4/storage/redis" + config "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/service" + "github.com/splitio/go-split-commons/v5/service/mocks" + predis "github.com/splitio/go-split-commons/v5/storage/redis" "github.com/splitio/go-toolkit/v5/logging" cconf "github.com/splitio/split-synchronizer/v5/splitio/common/conf" "github.com/splitio/split-synchronizer/v5/splitio/producer/conf" diff --git a/splitio/producer/storage/mocks/telemetry.go b/splitio/producer/storage/mocks/telemetry.go index 6aaba5fd..e7faad6c 100644 --- a/splitio/producer/storage/mocks/telemetry.go +++ b/splitio/producer/storage/mocks/telemetry.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" ) // RedisTelemetryConsumerMultiMock is a mock diff --git a/splitio/producer/storage/telemetry.go b/splitio/producer/storage/telemetry.go index 305e252c..b3ba6494 100644 --- a/splitio/producer/storage/telemetry.go +++ b/splitio/producer/storage/telemetry.go @@ -10,9 +10,9 @@ import ( "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/redis" - "github.com/splitio/go-split-commons/v4/dtos" - redisSt "github.com/splitio/go-split-commons/v4/storage/redis" - "github.com/splitio/go-split-commons/v4/telemetry" + "github.com/splitio/go-split-commons/v5/dtos" + redisSt "github.com/splitio/go-split-commons/v5/storage/redis" + "github.com/splitio/go-split-commons/v5/telemetry" ) const ( diff --git a/splitio/producer/storage/telemetry_test.go b/splitio/producer/storage/telemetry_test.go index 464c0b31..b93a12ab 100644 --- a/splitio/producer/storage/telemetry_test.go +++ b/splitio/producer/storage/telemetry_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v4/dtos" - redisSt "github.com/splitio/go-split-commons/v4/storage/redis" - "github.com/splitio/go-split-commons/v4/telemetry" + "github.com/splitio/go-split-commons/v5/dtos" + redisSt "github.com/splitio/go-split-commons/v5/storage/redis" + "github.com/splitio/go-split-commons/v5/telemetry" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/redis" ) diff --git a/splitio/producer/task/events.go b/splitio/producer/task/events.go index 1001a4c3..443072a8 100644 --- a/splitio/producer/task/events.go +++ b/splitio/producer/task/events.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/storage" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/storage" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" ) diff --git a/splitio/producer/task/events_test.go b/splitio/producer/task/events_test.go index 6fe47e42..c11aa3a8 100644 --- a/splitio/producer/task/events_test.go +++ b/splitio/producer/task/events_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/storage/mocks" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/storage/mocks" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" ) @@ -110,7 +110,7 @@ func TestEventsMemoryIsProperlyReturned(t *testing.T) { } for i := 0; i < 3; i++ { - i := <- sinker + i := <-sinker req, err := w.BuildRequest(i) if asRecyclable, ok := i.(recyclable); ok { asRecyclable.recycle() diff --git a/splitio/producer/task/impressions.go b/splitio/producer/task/impressions.go index 9d807a35..4c329627 100644 --- a/splitio/producer/task/impressions.go +++ b/splitio/producer/task/impressions.go @@ -8,9 +8,9 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/provisional" - "github.com/splitio/go-split-commons/v4/storage" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/provisional" + "github.com/splitio/go-split-commons/v5/storage" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" diff --git a/splitio/producer/task/impressions_test.go b/splitio/producer/task/impressions_test.go index accf8e14..b396ce83 100644 --- a/splitio/producer/task/impressions_test.go +++ b/splitio/producer/task/impressions_test.go @@ -11,11 +11,11 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/provisional" - "github.com/splitio/go-split-commons/v4/provisional/strategy" - "github.com/splitio/go-split-commons/v4/storage/inmemory" - "github.com/splitio/go-split-commons/v4/storage/mocks" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/provisional" + "github.com/splitio/go-split-commons/v5/provisional/strategy" + "github.com/splitio/go-split-commons/v5/storage/inmemory" + "github.com/splitio/go-split-commons/v5/storage/mocks" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" ) @@ -152,7 +152,7 @@ func TestMemoryIsProperlyReturned(t *testing.T) { } for i := 0; i < 3; i++ { - i := <- sinker + i := <-sinker req, err := w.BuildRequest(i) if asRecyclable, ok := i.(recyclable); ok { asRecyclable.recycle() @@ -257,4 +257,3 @@ func TestImpressionsIntegration(t *testing.T) { t.Errorf("machine0 should have %d impressions. Has %d", expectedImpressionsPerMeta, r) } } - diff --git a/splitio/producer/task/pipelined.go b/splitio/producer/task/pipelined.go index cbb3c71a..3a54f5ac 100644 --- a/splitio/producer/task/pipelined.go +++ b/splitio/producer/task/pipelined.go @@ -165,6 +165,10 @@ func (p *PipelinedSyncTask) filler() { for p.running.IsSet() { timer.Reset(1 * time.Second) raw, err := p.worker.Fetch() + if err != nil { + p.logger.Error(fmt.Sprintf("[pipelined/%s] fetch function returned error: %s", p.name, err)) + } + if len(raw) == 0 { select { case <-timer.C: @@ -174,11 +178,6 @@ func (p *PipelinedSyncTask) filler() { return } } - if err != nil { - p.logger.Error(fmt.Sprintf("[pipelined/%s] fetch function returned error: %s", p.name, err)) - continue - } - howMany := len(raw) select { case p.inputBuffer <- raw: diff --git a/splitio/producer/task/uniquekeys.go b/splitio/producer/task/uniquekeys.go index b8e01587..f3134ce1 100644 --- a/splitio/producer/task/uniquekeys.go +++ b/splitio/producer/task/uniquekeys.go @@ -6,9 +6,9 @@ import ( "fmt" "net/http" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/provisional/strategy" - "github.com/splitio/go-split-commons/v4/storage" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/provisional/strategy" + "github.com/splitio/go-split-commons/v5/storage" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/producer/task/uniquekeys_test.go b/splitio/producer/task/uniquekeys_test.go index 9889f0e6..4985bb62 100644 --- a/splitio/producer/task/uniquekeys_test.go +++ b/splitio/producer/task/uniquekeys_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "testing" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/provisional/strategy" - "github.com/splitio/go-split-commons/v4/storage/mocks" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/provisional/strategy" + "github.com/splitio/go-split-commons/v5/storage/mocks" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/producer/util.go b/splitio/producer/util.go index 15eef523..c0f24f69 100644 --- a/splitio/producer/util.go +++ b/splitio/producer/util.go @@ -12,13 +12,13 @@ import ( "strings" "time" - cconf "github.com/splitio/go-split-commons/v4/conf" - config "github.com/splitio/go-split-commons/v4/conf" - "github.com/splitio/go-split-commons/v4/provisional" - "github.com/splitio/go-split-commons/v4/provisional/strategy" - "github.com/splitio/go-split-commons/v4/service" - storageCommon "github.com/splitio/go-split-commons/v4/storage" - "github.com/splitio/go-split-commons/v4/storage/redis" + cconf "github.com/splitio/go-split-commons/v5/conf" + config "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v5/provisional" + "github.com/splitio/go-split-commons/v5/provisional/strategy" + "github.com/splitio/go-split-commons/v5/service" + storageCommon "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v5/storage/redis" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" "github.com/splitio/split-synchronizer/v5/splitio/producer/conf" diff --git a/splitio/producer/worker/impcounts.go b/splitio/producer/worker/impcounts.go index 071ca4a1..ef3dd124 100644 --- a/splitio/producer/worker/impcounts.go +++ b/splitio/producer/worker/impcounts.go @@ -1,8 +1,8 @@ package worker import ( - "github.com/splitio/go-split-commons/v4/provisional/strategy" - "github.com/splitio/go-split-commons/v4/storage" + "github.com/splitio/go-split-commons/v5/provisional/strategy" + "github.com/splitio/go-split-commons/v5/storage" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/producer/worker/telemetry.go b/splitio/producer/worker/telemetry.go index 078965e0..a92bf7a1 100644 --- a/splitio/producer/worker/telemetry.go +++ b/splitio/producer/worker/telemetry.go @@ -3,8 +3,8 @@ package worker import ( "fmt" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/service" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/service" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/storage" ) @@ -118,11 +118,11 @@ func (w *TelemetryMultiWorkerImpl) SyncrhonizeConfigs() error { // import ( // "sync" // -// "github.com/splitio/go-split-commons/v4/dtos" -// "github.com/splitio/go-split-commons/v4/service" -// "github.com/splitio/go-split-commons/v4/storage" +// "github.com/splitio/go-split-commons/v5/dtos" +// "github.com/splitio/go-split-commons/v5/service" +// "github.com/splitio/go-split-commons/v5/storage" // -// // "github.com/splitio/go-split-commons/v4/synchronizer/worker/metric" +// // "github.com/splitio/go-split-commons/v5/synchronizer/worker/metric" // "github.com/splitio/go-toolkit/v5/logging" // ) // diff --git a/splitio/producer/worker/telemetry_test.go b/splitio/producer/worker/telemetry_test.go index 2383eee0..55d15ee4 100644 --- a/splitio/producer/worker/telemetry_test.go +++ b/splitio/producer/worker/telemetry_test.go @@ -3,9 +3,9 @@ package worker import ( "testing" - "github.com/splitio/go-split-commons/v4/dtos" - serviceMocks "github.com/splitio/go-split-commons/v4/service/mocks" - "github.com/splitio/go-split-commons/v4/telemetry" + "github.com/splitio/go-split-commons/v5/dtos" + serviceMocks "github.com/splitio/go-split-commons/v5/service/mocks" + "github.com/splitio/go-split-commons/v5/telemetry" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/storage" storageMocks "github.com/splitio/split-synchronizer/v5/splitio/producer/storage/mocks" diff --git a/splitio/provisional/healthcheck/application/monitor_test.go b/splitio/provisional/healthcheck/application/monitor_test.go index 1a0efa12..50e55e97 100644 --- a/splitio/provisional/healthcheck/application/monitor_test.go +++ b/splitio/provisional/healthcheck/application/monitor_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v4/healthcheck/application" + "github.com/splitio/go-split-commons/v5/healthcheck/application" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/provisional/healthcheck/application/counter" ) diff --git a/splitio/provisional/healthcheck/services/counter/bypercentage.go b/splitio/provisional/healthcheck/services/counter/bypercentage.go index 6ac59bc9..0a18e274 100644 --- a/splitio/provisional/healthcheck/services/counter/bypercentage.go +++ b/splitio/provisional/healthcheck/services/counter/bypercentage.go @@ -6,10 +6,10 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v4/conf" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/service/api" - "github.com/splitio/go-split-commons/v4/service/api" "github.com/splitio/go-toolkit/v5/asynctask" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/provisional/observability/segment_wrapper.go b/splitio/provisional/observability/segment_wrapper.go index c57ed14a..d89f85b7 100644 --- a/splitio/provisional/observability/segment_wrapper.go +++ b/splitio/provisional/observability/segment_wrapper.go @@ -5,7 +5,8 @@ import ( "fmt" "sync" - "github.com/splitio/go-split-commons/v4/storage" + "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/provisional/observability/segment_wrapper_test.go b/splitio/provisional/observability/segment_wrapper_test.go index fdf4922f..aab99a50 100644 --- a/splitio/provisional/observability/segment_wrapper_test.go +++ b/splitio/provisional/observability/segment_wrapper_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/splitio/go-split-commons/v4/storage/mocks" + "github.com/splitio/go-split-commons/v5/storage/mocks" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/provisional/observability/split_wrapper.go b/splitio/provisional/observability/split_wrapper.go index 4147de06..dfc78c95 100644 --- a/splitio/provisional/observability/split_wrapper.go +++ b/splitio/provisional/observability/split_wrapper.go @@ -4,9 +4,9 @@ import ( "errors" "sync" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/storage" - "github.com/splitio/go-split-commons/v4/storage/redis" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v5/storage/redis" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/provisional/observability/split_wrapper_test.go b/splitio/provisional/observability/split_wrapper_test.go index 2e5e380c..6ac4c33d 100644 --- a/splitio/provisional/observability/split_wrapper_test.go +++ b/splitio/provisional/observability/split_wrapper_test.go @@ -4,9 +4,9 @@ import ( "errors" "testing" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/storage/mocks" - "github.com/splitio/go-split-commons/v4/storage/redis" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/storage/mocks" + "github.com/splitio/go-split-commons/v5/storage/redis" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/proxy/caching/caching.go b/splitio/proxy/caching/caching.go index ce14d3d9..29b65456 100644 --- a/splitio/proxy/caching/caching.go +++ b/splitio/proxy/caching/caching.go @@ -5,7 +5,7 @@ import ( "github.com/gin-gonic/gin" "github.com/splitio/gincache" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" ) const ( @@ -51,8 +51,11 @@ func MakeSurrogateForMySegments(mysegments []dtos.MySegmentDTO) []string { } // MakeMySegmentsEntry create a cache entry key for mysegments -func MakeMySegmentsEntry(key string) string { - return "/api/mySegments/" + key +func MakeMySegmentsEntries(key string) []string { + return []string{ + "/api/mySegments/" + key, + "gzip::/api/mySegments/" + key, + } } // MakeProxyCache creates and configures a split-proxy-ready cache @@ -61,12 +64,18 @@ func MakeProxyCache() *gincache.Middleware { SuccessfulOnly: true, // we're not interested in caching non-200 responses Size: cacheSize, KeyFactory: func(ctx *gin.Context) string { + + var encodingPrefix string + if strings.Contains(ctx.Request.Header.Get("Accept-Encoding"), "gzip") { + encodingPrefix = "gzip::" + } + if strings.HasPrefix(ctx.Request.URL.Path, "/api/auth") || strings.HasPrefix(ctx.Request.URL.Path, "/api/v2/auth") { // For auth requests, since we don't support streaming yet, we only need a single entry in the table, // so we strip the query-string which contains the user-list - return ctx.Request.URL.Path + return encodingPrefix + ctx.Request.URL.Path } - return ctx.Request.URL.Path + ctx.Request.URL.RawQuery + return encodingPrefix + ctx.Request.URL.Path + ctx.Request.URL.RawQuery }, // we make each request handler responsible for generating the surrogates. // this way we can use segment names as surrogates for mysegments & segment changes diff --git a/splitio/proxy/caching/caching_test.go b/splitio/proxy/caching/caching_test.go index cd02b73a..8d414cab 100644 --- a/splitio/proxy/caching/caching_test.go +++ b/splitio/proxy/caching/caching_test.go @@ -3,7 +3,7 @@ package caching import ( "testing" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/testhelpers" ) @@ -15,7 +15,11 @@ func TestSegment(t *testing.T) { } func TestMySegmentKeyGeneration(t *testing.T) { - if MakeMySegmentsEntry("k1") != "/api/mySegments/k1" { + entries := MakeMySegmentsEntries("k1") + if entries[0] != "/api/mySegments/k1" { + t.Error("invalid mySegments cache entry") + } + if entries[1] != "gzip::/api/mySegments/k1" { t.Error("invalid mySegments cache entry") } } diff --git a/splitio/proxy/caching/workers.go b/splitio/proxy/caching/workers.go index 685a4de3..cc4bff18 100644 --- a/splitio/proxy/caching/workers.go +++ b/splitio/proxy/caching/workers.go @@ -1,11 +1,12 @@ package caching import ( - "github.com/splitio/go-split-commons/v4/healthcheck/application" - "github.com/splitio/go-split-commons/v4/service" - "github.com/splitio/go-split-commons/v4/storage" - "github.com/splitio/go-split-commons/v4/synchronizer/worker/segment" - "github.com/splitio/go-split-commons/v4/synchronizer/worker/split" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/healthcheck/application" + "github.com/splitio/go-split-commons/v5/service" + "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v5/synchronizer/worker/segment" + "github.com/splitio/go-split-commons/v5/synchronizer/worker/split" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/gincache" @@ -28,7 +29,7 @@ func NewCacheAwareSplitSync( appMonitor application.MonitorProducerInterface, ) *CacheAwareSplitSynchronizer { return &CacheAwareSplitSynchronizer{ - wrapped: split.NewSplitFetcher(splitStorage, splitFetcher, logger, runtimeTelemetry, appMonitor), + wrapped: split.NewSplitUpdater(splitStorage, splitFetcher, logger, runtimeTelemetry, appMonitor), splitStorage: splitStorage, cacheFlusher: cacheFlusher, } @@ -52,6 +53,17 @@ func (c *CacheAwareSplitSynchronizer) LocalKill(splitName string, defaultTreatme c.cacheFlusher.EvictBySurrogate(SplitSurrogate) } +// SynchronizeFeatureFlags synchronizes feature flags and if something changes, purges the cache appropriately +func (c *CacheAwareSplitSynchronizer) SynchronizeFeatureFlags(ffChange *dtos.SplitChangeUpdate) (*split.UpdateResult, error) { + previous, _ := c.splitStorage.ChangeNumber() + result, err := c.wrapped.SynchronizeFeatureFlags(ffChange) + if current, _ := c.splitStorage.ChangeNumber(); current > previous || (previous != -1 && current == -1) { + // if the changenumber was updated, evict splitChanges responses from cache + c.cacheFlusher.EvictBySurrogate(SplitSurrogate) + } + return result, err +} + // CacheAwareSegmentSynchronizer wraps a segment-sync with cache-friendly logic type CacheAwareSegmentSynchronizer struct { wrapped segment.Updater @@ -71,7 +83,7 @@ func NewCacheAwareSegmentSync( appMonitor application.MonitorProducerInterface, ) *CacheAwareSegmentSynchronizer { return &CacheAwareSegmentSynchronizer{ - wrapped: segment.NewSegmentFetcher(splitStorage, segmentStorage, segmentFetcher, logger, runtimeTelemetry, appMonitor), + wrapped: segment.NewSegmentUpdater(splitStorage, segmentStorage, segmentFetcher, logger, runtimeTelemetry, appMonitor), cacheFlusher: cacheFlusher, splitStorage: splitStorage, segmentStorage: segmentStorage, @@ -88,7 +100,9 @@ func (c *CacheAwareSegmentSynchronizer) SynchronizeSegment(name string, till *in // remove individual entries for each affected key for idx := range result.UpdatedKeys { - c.cacheFlusher.Evict(MakeMySegmentsEntry(result.UpdatedKeys[idx])) + for _, key := range MakeMySegmentsEntries(result.UpdatedKeys[idx]) { + c.cacheFlusher.Evict(key) + } } return result, err @@ -116,7 +130,9 @@ func (c *CacheAwareSegmentSynchronizer) SynchronizeSegments() (map[string]segmen } for idx := range result.UpdatedKeys { - c.cacheFlusher.Evict(MakeMySegmentsEntry(result.UpdatedKeys[idx])) + for _, key := range MakeMySegmentsEntries(result.UpdatedKeys[idx]) { + c.cacheFlusher.Evict(key) + } } } diff --git a/splitio/proxy/caching/workers_test.go b/splitio/proxy/caching/workers_test.go index 201e4888..cb47f3e7 100644 --- a/splitio/proxy/caching/workers_test.go +++ b/splitio/proxy/caching/workers_test.go @@ -3,9 +3,10 @@ package caching import ( "testing" - storageMocks "github.com/splitio/go-split-commons/v4/storage/mocks" - "github.com/splitio/go-split-commons/v4/synchronizer/worker/segment" - "github.com/splitio/go-split-commons/v4/synchronizer/worker/split" + "github.com/splitio/go-split-commons/v5/dtos" + storageMocks "github.com/splitio/go-split-commons/v5/storage/mocks" + "github.com/splitio/go-split-commons/v5/synchronizer/worker/segment" + "github.com/splitio/go-split-commons/v5/synchronizer/worker/split" "github.com/splitio/go-toolkit/v5/datastructures/set" cacheMocks "github.com/splitio/gincache/mocks" @@ -15,8 +16,9 @@ func TestCacheAwareSplitSync(t *testing.T) { var cn int64 = -1 splitSyncMock := &splitUpdaterMock{ - SynchronizeSplitsCall: func(*int64) (*split.UpdateResult, error) { return nil, nil }, - LocalKillCall: func(string, string, int64) {}, + SynchronizeFeatureFlagsCall: func(ffChange *dtos.SplitChangeUpdate) (*split.UpdateResult, error) { return nil, nil }, + SynchronizeSplitsCall: func(*int64) (*split.UpdateResult, error) { return nil, nil }, + LocalKillCall: func(string, string, int64) {}, } cacheFlusherMock := &cacheMocks.CacheFlusherMock{ EvictBySurrogateCall: func(string) { t.Error("nothing should be evicted") }, @@ -67,6 +69,63 @@ func TestCacheAwareSplitSync(t *testing.T) { } } +func TestCacheAwareSplitSyncFF(t *testing.T) { + var cn int64 = -1 + + splitSyncMock := &splitUpdaterMock{ + SynchronizeFeatureFlagsCall: func(ffChange *dtos.SplitChangeUpdate) (*split.UpdateResult, error) { return nil, nil }, + SynchronizeSplitsCall: func(*int64) (*split.UpdateResult, error) { return nil, nil }, + LocalKillCall: func(string, string, int64) {}, + } + cacheFlusherMock := &cacheMocks.CacheFlusherMock{ + EvictBySurrogateCall: func(string) { t.Error("nothing should be evicted") }, + } + + css := CacheAwareSplitSynchronizer{ + splitStorage: &storageMocks.MockSplitStorage{ + ChangeNumberCall: func() (int64, error) { return cn, nil }, + }, + wrapped: splitSyncMock, + cacheFlusher: cacheFlusherMock, + } + + css.SynchronizeFeatureFlags(nil) + + splitSyncMock.SynchronizeFeatureFlagsCall = func(*dtos.SplitChangeUpdate) (*split.UpdateResult, error) { + cn++ + return nil, nil + } + + calls := 0 + cacheFlusherMock.EvictBySurrogateCall = func(key string) { + if key != SplitSurrogate { + t.Error("wrong surrogate") + } + calls++ + } + + css.SynchronizeFeatureFlags(nil) + if calls != 1 { + t.Error("should have flushed splits once") + } + + css.LocalKill("someSplit", "off", 123) + if calls != 2 { + t.Error("should have flushed again after a local kill") + } + + // Test that going from cn > -1 to cn == -1 purges + cn = 123 + splitSyncMock.SynchronizeFeatureFlagsCall = func(*dtos.SplitChangeUpdate) (*split.UpdateResult, error) { + cn = -1 + return nil, nil + } + css.SynchronizeFeatureFlags(nil) + if calls != 3 { + t.Error("should have flushed splits once", calls) + } +} + func TestCacheAwareSegmentSync(t *testing.T) { cns := map[string]int64{"segment1": 0} @@ -113,7 +172,7 @@ func TestCacheAwareSegmentSync(t *testing.T) { evictBySurrogateCalls++ } cacheFlusherMock.EvictCall = func(key string) { - if key != "/api/mySegments/k1" { + if key != "/api/mySegments/k1" && key != "gzip::/api/mySegments/k1" { t.Error("incorrect mysegments entry purged: ", key) } } @@ -208,8 +267,9 @@ func TestCacheAwareSegmentSync(t *testing.T) { } type splitUpdaterMock struct { - SynchronizeSplitsCall func(till *int64) (*split.UpdateResult, error) - LocalKillCall func(splitName string, defaultTreatment string, changeNumber int64) + SynchronizeFeatureFlagsCall func(ffChange *dtos.SplitChangeUpdate) (*split.UpdateResult, error) + SynchronizeSplitsCall func(till *int64) (*split.UpdateResult, error) + LocalKillCall func(splitName string, defaultTreatment string, changeNumber int64) } func (s *splitUpdaterMock) SynchronizeSplits(till *int64) (*split.UpdateResult, error) { @@ -220,6 +280,10 @@ func (s *splitUpdaterMock) LocalKill(splitName string, defaultTreatment string, s.LocalKillCall(splitName, defaultTreatment, changeNumber) } +func (s *splitUpdaterMock) SynchronizeFeatureFlags(ffChange *dtos.SplitChangeUpdate) (*split.UpdateResult, error) { + return s.SynchronizeFeatureFlagsCall(ffChange) +} + type segmentUpdaterMock struct { SynchronizeSegmentCall func(name string, till *int64) (*segment.UpdateResult, error) SynchronizeSegmentsCall func() (map[string]segment.UpdateResult, error) diff --git a/splitio/proxy/conf/sections.go b/splitio/proxy/conf/sections.go index 565fcec1..204720f5 100644 --- a/splitio/proxy/conf/sections.go +++ b/splitio/proxy/conf/sections.go @@ -1,7 +1,7 @@ package conf import ( - cconf "github.com/splitio/go-split-commons/v4/conf" + cconf "github.com/splitio/go-split-commons/v5/conf" "github.com/splitio/split-synchronizer/v5/splitio/common/conf" ) diff --git a/splitio/proxy/controllers/events.go b/splitio/proxy/controllers/events.go index a583a103..38ca22ab 100644 --- a/splitio/proxy/controllers/events.go +++ b/splitio/proxy/controllers/events.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" diff --git a/splitio/proxy/controllers/events_test.go b/splitio/proxy/controllers/events_test.go index c176a160..aee2ab7d 100644 --- a/splitio/proxy/controllers/events_test.go +++ b/splitio/proxy/controllers/events_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" ilMock "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener/mocks" diff --git a/splitio/proxy/controllers/sdk.go b/splitio/proxy/controllers/sdk.go index 1c58d824..3d68dbf2 100644 --- a/splitio/proxy/controllers/sdk.go +++ b/splitio/proxy/controllers/sdk.go @@ -7,8 +7,8 @@ import ( "strconv" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/service" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/service" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/proxy/caching" diff --git a/splitio/proxy/controllers/sdk_test.go b/splitio/proxy/controllers/sdk_test.go index caa6660a..e1eeb2c4 100644 --- a/splitio/proxy/controllers/sdk_test.go +++ b/splitio/proxy/controllers/sdk_test.go @@ -9,9 +9,9 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/service" - "github.com/splitio/go-split-commons/v4/service/mocks" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/service" + "github.com/splitio/go-split-commons/v5/service/mocks" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/proxy/storage" diff --git a/splitio/proxy/controllers/telemetry.go b/splitio/proxy/controllers/telemetry.go index f3ab0294..a6b02c3c 100644 --- a/splitio/proxy/controllers/telemetry.go +++ b/splitio/proxy/controllers/telemetry.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/proxy/internal" diff --git a/splitio/proxy/controllers/telemetry_test.go b/splitio/proxy/controllers/telemetry_test.go index 3c19f968..d67297a7 100644 --- a/splitio/proxy/controllers/telemetry_test.go +++ b/splitio/proxy/controllers/telemetry_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/proxy/controllers/middleware" "github.com/splitio/split-synchronizer/v5/splitio/proxy/internal" diff --git a/splitio/proxy/controllers/util.go b/splitio/proxy/controllers/util.go index 1ccb8aa8..d5326362 100644 --- a/splitio/proxy/controllers/util.go +++ b/splitio/proxy/controllers/util.go @@ -2,8 +2,8 @@ package controllers import ( "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v4/conf" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v5/dtos" ) func metadataFromHeaders(ctx *gin.Context) dtos.Metadata { diff --git a/splitio/proxy/initialization.go b/splitio/proxy/initialization.go index 09e5f3b8..8b4ec7f5 100644 --- a/splitio/proxy/initialization.go +++ b/splitio/proxy/initialization.go @@ -9,11 +9,11 @@ import ( "strings" - "github.com/splitio/go-split-commons/v4/conf" - "github.com/splitio/go-split-commons/v4/service/api" - "github.com/splitio/go-split-commons/v4/synchronizer" - "github.com/splitio/go-split-commons/v4/tasks" - "github.com/splitio/go-split-commons/v4/telemetry" + "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v5/service/api" + "github.com/splitio/go-split-commons/v5/synchronizer" + "github.com/splitio/go-split-commons/v5/tasks" + "github.com/splitio/go-split-commons/v5/telemetry" "github.com/splitio/go-toolkit/v5/backoff" "github.com/splitio/go-toolkit/v5/logging" @@ -112,8 +112,8 @@ func Start(logger logging.LoggerInterface, cfg *pconf.Main) error { // setup feature flags, segments & local telemetry API interactions workers := synchronizer.Workers{ - SplitFetcher: caching.NewCacheAwareSplitSync(splitStorage, splitAPI.SplitFetcher, logger, localTelemetryStorage, httpCache, appMonitor), - SegmentFetcher: caching.NewCacheAwareSegmentSync(splitStorage, segmentStorage, splitAPI.SegmentFetcher, logger, localTelemetryStorage, httpCache, + SplitUpdater: caching.NewCacheAwareSplitSync(splitStorage, splitAPI.SplitFetcher, logger, localTelemetryStorage, httpCache, appMonitor), + SegmentUpdater: caching.NewCacheAwareSegmentSync(splitStorage, segmentStorage, splitAPI.SegmentFetcher, logger, localTelemetryStorage, httpCache, appMonitor), TelemetryRecorder: telemetry.NewTelemetrySynchronizer(localTelemetryStorage, telemetryRecorder, splitStorage, segmentStorage, logger, metadata, localTelemetryStorage), @@ -121,8 +121,8 @@ func Start(logger logging.LoggerInterface, cfg *pconf.Main) error { // setup periodic tasks in case streaming is disabled or we need to fall back to polling stasks := synchronizer.SplitTasks{ - SplitSyncTask: tasks.NewFetchSplitsTask(workers.SplitFetcher, int(cfg.Sync.SplitRefreshRateMs/1000), logger), - SegmentSyncTask: tasks.NewFetchSegmentsTask(workers.SegmentFetcher, int(cfg.Sync.SegmentRefreshRateMs/1000), advanced.SegmentWorkers, + SplitSyncTask: tasks.NewFetchSplitsTask(workers.SplitUpdater, int(cfg.Sync.SplitRefreshRateMs/1000), logger), + SegmentSyncTask: tasks.NewFetchSegmentsTask(workers.SegmentUpdater, int(cfg.Sync.SegmentRefreshRateMs/1000), advanced.SegmentWorkers, advanced.SegmentQueueSize, logger), TelemetrySyncTask: tasks.NewRecordTelemetryTask(workers.TelemetryRecorder, int(cfg.Sync.Advanced.InternalMetricsRateMs), logger), ImpressionSyncTask: impressionTask, @@ -131,7 +131,7 @@ func Start(logger logging.LoggerInterface, cfg *pconf.Main) error { } // Creating Synchronizer for tasks - sync := ssync.NewSynchronizer(*advanced, stasks, workers, logger, nil, []tasks.Task{telemetryConfigTask, telemetryUsageTask, telemetryKeysClientSideTask, telemetryKeysServerSideTask}, appMonitor) + sync := ssync.NewSynchronizer(*advanced, stasks, workers, logger, nil, []tasks.Task{telemetryConfigTask, telemetryUsageTask, telemetryKeysClientSideTask, telemetryKeysServerSideTask}) mstatus := make(chan int, 1) syncManager, err := synchronizer.NewSynchronizerManager( diff --git a/splitio/proxy/initialization_test.go b/splitio/proxy/initialization_test.go index 8a6d87da..37c5ad8a 100644 --- a/splitio/proxy/initialization_test.go +++ b/splitio/proxy/initialization_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v4/synchronizer" + "github.com/splitio/go-split-commons/v5/synchronizer" ) type syncManagerMock struct { diff --git a/splitio/proxy/internal/dtos.go b/splitio/proxy/internal/dtos.go index 7a7d1f29..686fd036 100644 --- a/splitio/proxy/internal/dtos.go +++ b/splitio/proxy/internal/dtos.go @@ -1,10 +1,10 @@ package internal import ( - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" ) -//RawData represents the raw data submitted by an sdk when posting data with associated metadata +// RawData represents the raw data submitted by an sdk when posting data with associated metadata type RawData struct { Metadata dtos.Metadata Payload []byte diff --git a/splitio/proxy/proxy.go b/splitio/proxy/proxy.go index b0312a8d..f35dac9e 100644 --- a/splitio/proxy/proxy.go +++ b/splitio/proxy/proxy.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/splitio/go-split-commons/v4/service" + "github.com/splitio/go-split-commons/v5/service" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" diff --git a/splitio/proxy/proxy_test.go b/splitio/proxy/proxy_test.go index f0e1a0c2..1cf9c841 100644 --- a/splitio/proxy/proxy_test.go +++ b/splitio/proxy/proxy_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v4/dtos" - serviceMocks "github.com/splitio/go-split-commons/v4/service/mocks" + "github.com/splitio/go-split-commons/v5/dtos" + serviceMocks "github.com/splitio/go-split-commons/v5/service/mocks" "github.com/splitio/go-toolkit/v5/logging" ilmock "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener/mocks" "github.com/splitio/split-synchronizer/v5/splitio/proxy/caching" @@ -239,7 +239,9 @@ func TestSegmentChangesAndMySegmentsEndpoints(t *testing.T) { } // Same for mysegments - opts.Cache.Evict(caching.MakeMySegmentsEntry("k1")) + entries := caching.MakeMySegmentsEntries("k1") + opts.Cache.Evict(entries[0]) + opts.Cache.Evict(entries[1]) _, body, headers = get("mySegments/k1", opts.Port, map[string]string{"Authorization": "Bearer someApiKey"}) segments = toMySegments(body) if len(segments) != 0 { diff --git a/splitio/proxy/storage/mocks/mocks.go b/splitio/proxy/storage/mocks/mocks.go index 42cce30f..2134054c 100644 --- a/splitio/proxy/storage/mocks/mocks.go +++ b/splitio/proxy/storage/mocks/mocks.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" ) type ProxySplitStorageMock struct { diff --git a/splitio/proxy/storage/optimized/changesummary.go b/splitio/proxy/storage/optimized/changesummary.go index 0f5221e2..d34cbd03 100644 --- a/splitio/proxy/storage/optimized/changesummary.go +++ b/splitio/proxy/storage/optimized/changesummary.go @@ -5,7 +5,7 @@ import ( "math" "sync" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" ) // ErrUnknownChangeNumber is returned when trying to fetch a recipe for a change number not present in cache @@ -20,11 +20,15 @@ type SplitMinimalView struct { // ChangeSummary represents a set of changes from/in a specific point in time type ChangeSummary struct { Updated map[string]string // feature flag name -> trafficType - Removed map[string]string // featyre flag name -> trafficType + Removed map[string]string // feature flag name -> trafficType + Current *splitSet // list of splits originally available at this point in time } -func newEmptyChangeSummary() ChangeSummary { - return ChangeSummary{Updated: map[string]string{}, Removed: map[string]string{}} +func newEmptyChangeSummary(ss *splitSet) ChangeSummary { + if ss == nil { + ss = newSplitSet() + } + return ChangeSummary{Updated: map[string]string{}, Removed: map[string]string{}, Current: ss} } func (c *ChangeSummary) applyChange(toAdd []SplitMinimalView, toRemove []SplitMinimalView) { @@ -36,7 +40,9 @@ func (c *ChangeSummary) applyChange(toAdd []SplitMinimalView, toRemove []SplitMi for _, split := range toRemove { if _, ok := c.Updated[split.Name]; ok { delete(c.Updated, split.Name) - } else { + } + + if c.Current.contains(split.Name) { c.Removed[split.Name] = split.TrafficType } } @@ -56,7 +62,7 @@ func NewSplitChangesSummaries(maxRecipes int) *SplitChangesSummaries { return &SplitChangesSummaries{ maxRecipes: maxRecipes + 1, // we keep an extra slot for -1 which is fixed currentCN: -1, - changes: map[int64]ChangeSummary{-1: newEmptyChangeSummary()}, + changes: map[int64]ChangeSummary{-1: newEmptyChangeSummary(nil)}, } } @@ -67,6 +73,17 @@ func (s *SplitChangesSummaries) AddChanges(added []dtos.SplitDTO, removed []dtos addedViews := toSplitMinimalViews(added) removedViews := toSplitMinimalViews(removed) + + if cn == -1 { + // During the first hit (cn=-1) we want to capture ALL split names, to form an initial snapshot of what the user will get + // and nothing else. + ss := newSplitSet() + ss.update(addedViews, nil) + cs := s.changes[0] + cs.Current = ss + s.changes[0] = cs + } + if cn <= s.currentCN { return } @@ -75,13 +92,23 @@ func (s *SplitChangesSummaries) AddChanges(added []dtos.SplitDTO, removed []dtos s.removeOldestRecipe() } + var lastCheckpoint int64 = -1 + lastSplitSet := newSplitSet() for key, summary := range s.changes { + if key > lastCheckpoint { + lastCheckpoint = key + lastSplitSet = summary.Current + } + summary.applyChange(addedViews, removedViews) s.changes[key] = summary } s.currentCN = cn - s.changes[cn] = newEmptyChangeSummary() + + newSS := lastSplitSet.clone() + newSS.update(addedViews, removedViews) + s.changes[cn] = newEmptyChangeSummary(newSS) } // AddOlderChange is used to add a change older than the oldest one currently stored (when the sync started) @@ -99,7 +126,7 @@ func (s *SplitChangesSummaries) AddOlderChange(added []dtos.SplitDTO, removed [] s.removeOldestRecipe() } - summary := newEmptyChangeSummary() + summary := newEmptyChangeSummary(nil) // TODO(mredolatti): see if we can do better than this for _, split := range added { summary.Updated[split.Name] = split.TrafficTypeName } @@ -169,3 +196,34 @@ func toSplitMinimalViews(items []dtos.SplitDTO) []SplitMinimalView { } return views } + +type splitSet struct { + data map[string]struct{} +} + +func newSplitSet() *splitSet { + return &splitSet{data: make(map[string]struct{})} +} + +func (s *splitSet) clone() *splitSet { + x := newSplitSet() + for key := range s.data { + x.data[key] = struct{}{} + } + return x +} + +func (s *splitSet) update(toAdd []SplitMinimalView, toRemove []SplitMinimalView) { + for idx := range toAdd { + s.data[toAdd[idx].Name] = struct{}{} + } + + for idx := range toRemove { + delete(s.data, toRemove[idx].Name) + } +} + +func (s *splitSet) contains(name string) bool { + _, ok := s.data[name] + return ok +} diff --git a/splitio/proxy/storage/optimized/changesummary_test.go b/splitio/proxy/storage/optimized/changesummary_test.go index 4df5ec06..5c87f87f 100644 --- a/splitio/proxy/storage/optimized/changesummary_test.go +++ b/splitio/proxy/storage/optimized/changesummary_test.go @@ -3,7 +3,7 @@ package optimized import ( "testing" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" ) func stringSlicesEqual(a []string, b []string) bool { @@ -227,7 +227,24 @@ func TestSizeBoundaries(t *testing.T) { if err != ErrUnknownChangeNumber { t.Error("should have gotten unknown CN error. Got: ", err) } +} +func TestSplitSet(t *testing.T) { + ss := newSplitSet() + ss.update([]SplitMinimalView{{Name: "s1"}, {Name: "s2"}}, nil) + if !ss.contains("s1") || !ss.contains("s2") { + t.Error("splitSet should contain s1 & s2") + } + + clone := ss.clone() + if !clone.contains("s1") || !clone.contains("s2") { + t.Error("splitSet should contain s1 & s2") + } + + ss.update(nil, []SplitMinimalView{{Name: "s2"}}) + if !clone.contains("s1") { + t.Error("splitSet should contain s1") + } } /* TEST PLAN! diff --git a/splitio/proxy/storage/persistent/splits.go b/splitio/proxy/storage/persistent/splits.go index 2343a3fb..0b450950 100644 --- a/splitio/proxy/storage/persistent/splits.go +++ b/splitio/proxy/storage/persistent/splits.go @@ -6,7 +6,7 @@ import ( "encoding/json" "sync" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/proxy/storage/persistent/splits_test.go b/splitio/proxy/storage/persistent/splits_test.go index ebbb1ddd..d6919a62 100644 --- a/splitio/proxy/storage/persistent/splits_test.go +++ b/splitio/proxy/storage/persistent/splits_test.go @@ -3,7 +3,7 @@ package persistent import ( "testing" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/proxy/storage/segments.go b/splitio/proxy/storage/segments.go index b3ec4558..65168b5e 100644 --- a/splitio/proxy/storage/segments.go +++ b/splitio/proxy/storage/segments.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/storage" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/storage" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" diff --git a/splitio/proxy/storage/splits.go b/splitio/proxy/storage/splits.go index 8a1d635b..bc4a99d3 100644 --- a/splitio/proxy/storage/splits.go +++ b/splitio/proxy/storage/splits.go @@ -5,9 +5,9 @@ import ( "fmt" "sync" - "github.com/splitio/go-split-commons/v4/dtos" - "github.com/splitio/go-split-commons/v4/storage" - "github.com/splitio/go-split-commons/v4/storage/inmemory/mutexmap" + "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v5/storage/inmemory/mutexmap" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" diff --git a/splitio/proxy/storage/splits_test.go b/splitio/proxy/storage/splits_test.go index c92644cc..7365564c 100644 --- a/splitio/proxy/storage/splits_test.go +++ b/splitio/proxy/storage/splits_test.go @@ -5,7 +5,7 @@ import ( "github.com/splitio/split-synchronizer/v5/splitio/proxy/storage/persistent" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/logging" ) @@ -23,7 +23,6 @@ func TestSplitStorage(t *testing.T) { {Name: "s2", ChangeNumber: 2, Status: "ACTIVE"}, }, nil, 1) - pss := NewProxySplitStorage(dbw, logger, true) sinceMinus1, currentCN, err := pss.recipes.FetchSince(-1) @@ -61,4 +60,3 @@ func TestSplitStorage(t *testing.T) { } } - diff --git a/splitio/proxy/storage/telemetry.go b/splitio/proxy/storage/telemetry.go index d6ac5d7a..341f9615 100644 --- a/splitio/proxy/storage/telemetry.go +++ b/splitio/proxy/storage/telemetry.go @@ -4,9 +4,9 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v4/storage" - "github.com/splitio/go-split-commons/v4/storage/inmemory" - "github.com/splitio/go-split-commons/v4/telemetry" + "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v5/storage/inmemory" + "github.com/splitio/go-split-commons/v5/telemetry" ) // Local telemetry constants diff --git a/splitio/proxy/storage/telemetryts.go b/splitio/proxy/storage/telemetryts.go index 7cf9046e..2f5411b0 100644 --- a/splitio/proxy/storage/telemetryts.go +++ b/splitio/proxy/storage/telemetryts.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v4/storage" + "github.com/splitio/go-split-commons/v5/storage" ) // Granularity selection constants to be used upon component instantiation diff --git a/splitio/proxy/tasks/deferred.go b/splitio/proxy/tasks/deferred.go index 84fe8df2..571fed85 100644 --- a/splitio/proxy/tasks/deferred.go +++ b/splitio/proxy/tasks/deferred.go @@ -4,7 +4,7 @@ import ( "errors" "sync" - "github.com/splitio/go-split-commons/v4/tasks" + "github.com/splitio/go-split-commons/v5/tasks" "github.com/splitio/go-toolkit/v5/asynctask" "github.com/splitio/go-toolkit/v5/logging" gtSync "github.com/splitio/go-toolkit/v5/sync" diff --git a/splitio/proxy/tasks/events.go b/splitio/proxy/tasks/events.go index 6b404aca..672f74d2 100644 --- a/splitio/proxy/tasks/events.go +++ b/splitio/proxy/tasks/events.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v4/service/api" + "github.com/splitio/go-split-commons/v5/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/proxy/tasks/impcount.go b/splitio/proxy/tasks/impcount.go index 29fec4d4..b5ffb0b9 100644 --- a/splitio/proxy/tasks/impcount.go +++ b/splitio/proxy/tasks/impcount.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v4/service/api" + "github.com/splitio/go-split-commons/v5/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/proxy/tasks/impressions.go b/splitio/proxy/tasks/impressions.go index 2be618a6..bbf82d0a 100644 --- a/splitio/proxy/tasks/impressions.go +++ b/splitio/proxy/tasks/impressions.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v4/service/api" + "github.com/splitio/go-split-commons/v5/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/proxy/tasks/telemetry.go b/splitio/proxy/tasks/telemetry.go index 574e414e..a3e9edce 100644 --- a/splitio/proxy/tasks/telemetry.go +++ b/splitio/proxy/tasks/telemetry.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v4/service/api" + "github.com/splitio/go-split-commons/v5/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/util/utils.go b/splitio/util/utils.go index 136c3189..023b9971 100644 --- a/splitio/util/utils.go +++ b/splitio/util/utils.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/splitio/go-split-commons/v4/dtos" + "github.com/splitio/go-split-commons/v5/dtos" "github.com/splitio/go-toolkit/v5/hasher" "github.com/splitio/go-toolkit/v5/nethelpers" "github.com/splitio/split-synchronizer/v5/splitio" diff --git a/splitio/version.go b/splitio/version.go index 22e967f5..84a70c52 100644 --- a/splitio/version.go +++ b/splitio/version.go @@ -2,4 +2,4 @@ package splitio // Version is the version of this Agent -const Version = "5.3.2" +const Version = "5.4.0"