Skip to content

Commit fba2b0f

Browse files
authored
Merge pull request #42 from splitio/http_healthcheck
http healtcheck
2 parents fedbf07 + 371a3ea commit fba2b0f

File tree

19 files changed

+597
-34
lines changed

19 files changed

+597
-34
lines changed

CHANGES

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
1.5.0 (Jan 17, 2025):
1+
1.6.0 (Feb 5, 2025)
2+
- Added Health & Readiness endpoints.
3+
- Fixing vulnerabilities.
4+
5+
1.5.0 (Jan 29, 2025):
26
- Added support for the new impressions tracking toggle available on feature flags, both respecting the setting and including the new field being returned on SplitView type objects. Read more in our docs.
37

48
1.4.0 (May 14, 2024):

cmd/splitd/main.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/splitio/go-toolkit/v5/logging"
99
"github.com/splitio/splitd/splitio"
10+
"github.com/splitio/splitd/splitio/api"
1011
"github.com/splitio/splitd/splitio/conf"
1112
"github.com/splitio/splitd/splitio/link"
1213
"github.com/splitio/splitd/splitio/sdk"
@@ -58,6 +59,9 @@ func main() {
5859
}()
5960
}
6061

62+
// launch api in BG (errors will be logged but won't abort execution of app)
63+
go startAPI(logger, cfg.API, *linkCFG)
64+
6165
// Wait for connection to end (either gracefully of because of an error)
6266
err = <-errc
6367
exitOnErr("shutdown: ", err)
@@ -84,3 +88,15 @@ func exitOnErr(ctxStr string, err error) {
8488
}
8589

8690
}
91+
92+
func startAPI(logger logging.LoggerInterface, apiCFG conf.API, linkCFG link.ListenerOptions) {
93+
server, err := api.Setup(apiCFG.Host, apiCFG.Port, logger, linkCFG)
94+
if err != nil {
95+
logger.Error("error creating HTTP server:", err.Error())
96+
return
97+
}
98+
99+
if err = server.ListenAndServe(); err != nil {
100+
logger.Error("error starting http server:", err.Error())
101+
}
102+
}

go.mod

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,48 @@
11
module github.com/splitio/splitd
22

3-
go 1.21
3+
go 1.23.6
44

55
require (
6+
github.com/gin-gonic/gin v1.10.0
67
github.com/splitio/go-split-commons/v6 v6.1.0
78
github.com/splitio/go-toolkit/v5 v5.4.0
89
github.com/stretchr/testify v1.9.0
910
github.com/vmihailenco/msgpack/v5 v5.3.5
10-
golang.org/x/sync v0.3.0
11+
golang.org/x/sync v0.10.0
1112
gopkg.in/yaml.v3 v3.0.1
1213
)
1314

1415
require (
1516
github.com/bits-and-blooms/bitset v1.3.1 // indirect
1617
github.com/bits-and-blooms/bloom/v3 v3.3.1 // indirect
18+
github.com/bytedance/sonic v1.11.6 // indirect
19+
github.com/bytedance/sonic/loader v0.1.1 // indirect
20+
github.com/cloudwego/base64x v0.1.4 // indirect
21+
github.com/cloudwego/iasm v0.2.0 // indirect
1722
github.com/davecgh/go-spew v1.1.1 // indirect
23+
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
24+
github.com/gin-contrib/sse v0.1.0 // indirect
25+
github.com/go-playground/locales v0.14.1 // indirect
26+
github.com/go-playground/universal-translator v0.18.1 // indirect
27+
github.com/go-playground/validator/v10 v10.20.0 // indirect
28+
github.com/goccy/go-json v0.10.2 // indirect
29+
github.com/json-iterator/go v1.1.12 // indirect
30+
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
31+
github.com/leodido/go-urn v1.4.0 // indirect
32+
github.com/mattn/go-isatty v0.0.20 // indirect
33+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
34+
github.com/modern-go/reflect2 v1.0.2 // indirect
35+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
1836
github.com/pmezard/go-difflib v1.0.0 // indirect
1937
github.com/stretchr/objx v0.5.2 // indirect
38+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
39+
github.com/ugorji/go/codec v1.2.12 // indirect
2040
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
41+
golang.org/x/arch v0.8.0 // indirect
42+
golang.org/x/crypto v0.32.0 // indirect
2143
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
44+
golang.org/x/net v0.34.0 // indirect
45+
golang.org/x/sys v0.29.0 // indirect
46+
golang.org/x/text v0.21.0 // indirect
47+
google.golang.org/protobuf v1.34.1 // indirect
2248
)

go.sum

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,106 @@ github.com/bits-and-blooms/bitset v1.3.1 h1:y+qrlmq3XsWi+xZqSaueaE8ry8Y127iMxlMf
22
github.com/bits-and-blooms/bitset v1.3.1/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
33
github.com/bits-and-blooms/bloom/v3 v3.3.1 h1:K2+A19bXT8gJR5mU7y+1yW6hsKfNCjcP2uNfLFKncjQ=
44
github.com/bits-and-blooms/bloom/v3 v3.3.1/go.mod h1:bhUUknWd5khVbTe4UgMCSiOOVJzr3tMoijSK3WwvW90=
5+
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
6+
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
7+
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
8+
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
9+
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
10+
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
11+
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
12+
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
513
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
614
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
715
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
16+
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
17+
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
18+
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
19+
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
20+
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
21+
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
22+
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
23+
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
24+
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
25+
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
26+
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
27+
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
28+
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
29+
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
30+
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
31+
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
32+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
33+
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
34+
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
35+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
36+
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
37+
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
38+
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
39+
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
40+
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
41+
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
42+
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
43+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
44+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
45+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
46+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
47+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
48+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
49+
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
50+
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
51+
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
852
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
953
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1054
github.com/splitio/go-split-commons/v6 v6.1.0 h1:k3mwr12DF6gbEaV8XXU/tSAQlPkIEuzIgTEneYhGg2I=
1155
github.com/splitio/go-split-commons/v6 v6.1.0/go.mod h1:D/XIY/9Hmfk9ivWsRsJVp439kEdmHbzUi3PKzQQDOXY=
1256
github.com/splitio/go-toolkit/v5 v5.4.0 h1:g5WFpRhQomnXCmvfsNOWV4s5AuUrWIZ+amM68G8NBKM=
1357
github.com/splitio/go-toolkit/v5 v5.4.0/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko=
1458
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
59+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
60+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
1561
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
1662
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
63+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
1764
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
65+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
66+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
67+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
68+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
69+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
1870
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
1971
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
72+
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
73+
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
2074
github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg=
2175
github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ=
76+
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
77+
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
2278
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
2379
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
2480
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
2581
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
82+
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
83+
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
84+
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
85+
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
86+
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
2687
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
2788
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
28-
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
29-
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
89+
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
90+
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
91+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
92+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
93+
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
94+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
95+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
96+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
97+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
98+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
99+
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
100+
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
30101
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
31102
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
32103
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
33104
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
34105
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
106+
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
107+
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

infra/entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ fi
7373
[ ! -z ${SPLITD_LOG_LEVEL+x} ] && accum=$(echo "${accum}" | yq '.logging.level = env(SPLITD_LOG_LEVEL)')
7474
[ ! -z ${SPLITD_LOG_OUTPUT+x} ] && accum=$(echo "${accum}" | yq '.logging.output = env(SPLITD_LOG_OUTPUT)')
7575

76+
# API configs
77+
[ ! -z ${SPLITD_API_HOST+x} ] && accum=$(echo "${accum}" | yq '.api.host = env(SPLITD_API_HOST)')
78+
[ ! -z ${SPLITD_API_PORT+x} ] && accum=$(echo "${accum}" | yq '.api.port = env(SPLITD_API_PORT)')
79+
7680
# profiling configs
7781
[ ! -z ${SPLITD_PROFILING_ENABLE+x} ] && accum=$(echo "${accum}" | yq '.debug.profiling.enable = env(SPLITD_PROFILING_ENABLE)')
7882
[ ! -z ${SPLITD_PROFILING_HOST+x} ] && accum=$(echo "${accum}" | yq '.debug.profiling.host = env(SPLITD_PROFILING_HOST)')

infra/sidecar.Dockerfile

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,42 @@
11
# ----- Builder image
2-
FROM golang:1.21.6-bookworm AS builder
2+
ARG GOLANG_VERSION=1.23.6
3+
FROM golang:${GOLANG_VERSION}-bookworm AS builder
34

45
ARG FIPS_MODE
56
ARG COMMIT_SHA
67

7-
RUN apt update -y
8-
RUN apt install -y build-essential ca-certificates python3 git socat
8+
RUN DEBIAN_FRONTEND=noninteractive \
9+
apt-get update && \
10+
apt-get install --no-install-recommends -y \
11+
build-essential ca-certificates python3 git socat
912

1013
WORKDIR /splitd
1114
COPY . .
1215

1316
RUN export GITHUB_SHA="${COMMIT_SHA}" && bash -c '\
14-
if [[ "${FIPS_MODE}" = "enabled" ]]; \
15-
then echo "building in fips mode"; make clean splitd-fips splitd.yaml.tpl EXTRA_BUILD_ARGS="${EXTRA_BUILD_ARGS}"; mv splitd-fips splitd; \
16-
else echo "building in standard mode"; make clean splitd splitd.yaml.tpl EXTRA_BUILD_ARGS="${EXTRA_BUILD_ARGS}"; \
17-
fi'
17+
if [[ "${FIPS_MODE}" = "enabled" ]]; \
18+
then echo "building in fips mode"; make clean splitd-fips splitd.yaml.tpl EXTRA_BUILD_ARGS="${EXTRA_BUILD_ARGS}"; mv splitd-fips splitd; \
19+
else echo "building in standard mode"; make clean splitd splitd.yaml.tpl EXTRA_BUILD_ARGS="${EXTRA_BUILD_ARGS}"; \
20+
fi'
1821

1922
# ----- Runner image
20-
FROM debian:12.4 AS runner
23+
FROM debian:bookworm-20250203-slim AS runner
2124

22-
RUN apt update -y
23-
RUN apt install -y bash ca-certificates wget socat
25+
ARG YQ_VERSION=v4.44.6
2426

25-
RUN wget https://github.com/mikefarah/yq/releases/download/v4.40.5/yq_linux_amd64
26-
RUN chmod +x yq_linux_amd64
27-
RUN mv yq_linux_amd64 /usr/local/bin/yq
27+
RUN DEBIAN_FRONTEND=noninteractive \
28+
apt-get update && \
29+
apt-get install --no-install-recommends -y \
30+
bash ca-certificates wget socat && \
31+
wget -O /usr/local/bin/yq \
32+
"https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" && \
33+
chmod +x /usr/local/bin/yq && \
34+
mkdir -p /opt/splitd && \
35+
rm -rf /var/lib/apt/lists/*
2836

29-
RUN mkdir -p /opt/splitd
3037
COPY --from=builder /splitd/splitd /opt/splitd
3138
COPY --from=builder /splitd/splitd.yaml.tpl /opt/splitd
3239
COPY infra/entrypoint.sh /opt/splitd
3340
RUN chmod +x /opt/splitd/entrypoint.sh
3441

35-
ENTRYPOINT ["/opt/splitd/entrypoint.sh"]
42+
ENTRYPOINT ["/opt/splitd/entrypoint.sh"]

infra/test/test_entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ function testAllVars {
5353
export SPLITD_EVENTS_REFRESH_SECS="11"
5454
export SPLITD_EVENTS_QUEUE_SIZE="12"
5555

56+
export SPLITD_API_HOST="someHost"
57+
export SPLITD_API_PORT="1111"
58+
5659
export SPLITD_PROFILING_ENABLE="true"
5760
export SPLITD_PROFILING_HOST="somehost"
5861
export SPLITD_PROFILING_PORT="1234"
@@ -99,6 +102,11 @@ function testAllVars {
99102
assert_eq "4" $(echo "$conf_json" | jq '.Link.AcceptTimeoutMS') "incorrect accept timeout"
100103
assert_eq "5" $(echo "$conf_json" | jq '.Link.BufferSize') "incorrect buffer size"
101104

105+
# ---
106+
107+
assert_eq '"someHost"' $(echo "$conf_json" | jq '.API.Host') "incorrect api host"
108+
assert_eq "1111" $(echo "$conf_json" | jq '.API.Port') "incorrect api port"
109+
102110
# ---
103111

104112
assert_eq "true" $(echo "$conf_json" | jq '.Debug.Profiling.Enable') "incorrect profiling status"

splitd.yaml.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ sdk:
3030
events:
3131
refreshRateSeconds: 60
3232
queueSize: 8192
33+
flagSetsFilter: []
3334
link:
3435
type: unix-seqpacket
3536
address: /var/run/splitd.sock
@@ -45,4 +46,7 @@ debug:
4546
enable: false
4647
host: localhost
4748
port: 8888
49+
api:
50+
host: 0.0.0.0
51+
port: 8887
4852

splitio/api/api.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package api
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"os"
7+
"strconv"
8+
9+
"github.com/gin-gonic/gin"
10+
"github.com/splitio/go-toolkit/v5/logging"
11+
"github.com/splitio/splitd/splitio/api/controllers"
12+
"github.com/splitio/splitd/splitio/link"
13+
"github.com/splitio/splitd/splitio/link/client"
14+
)
15+
16+
func Setup(host string, port int, logger logging.LoggerInterface, listenerCfG link.ListenerOptions) (*http.Server, error) {
17+
18+
router := gin.Default()
19+
mainAPI := router.Group("/api")
20+
21+
healthCtrl := controllers.NewHealthController(logger, link.ConsumerOptions{
22+
Transfer: listenerCfG.Transfer,
23+
Consumer: client.Options{
24+
ID: strconv.Itoa(os.Getpid()),
25+
Protocol: listenerCfG.Protocol,
26+
ImpressionsFeedback: false,
27+
},
28+
Serialization: listenerCfG.Serialization,
29+
})
30+
31+
healthCtrl.Register(mainAPI)
32+
33+
return &http.Server{
34+
Addr: fmt.Sprintf("%s:%d", host, port),
35+
Handler: router,
36+
}, nil
37+
}

splitio/api/controllers/dtos.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package controllers
2+
3+
type SplitViewDTO struct {
4+
Name string `json:"name"`
5+
TrafficType string `json:"trafficType"`
6+
Killed bool `json:"killed"`
7+
Treatments []string `json:"treatments"`
8+
ChangeNumber int64 `json:"changeNumber"`
9+
Configs map[string]string `json:"configs"`
10+
DefaultTreatment string `json:"defaultTreatment"`
11+
Sets []string `json:"sets"`
12+
ImpressionsDisabled bool `json:"impressionsDisabled"`
13+
}

0 commit comments

Comments
 (0)