Skip to content

Commit 8fbd1d5

Browse files
fix: move health endpoint to API server (#104)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> moved health endpoint to api server ## Related Issue Or Context <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Otherwise, describe context and motivation for change herre --> Closes: #102 ## How Has This Been Tested? Testing details. <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have ensured that all acceptance criteria (or expected behavior) from issue are met - [ ] I have updated the documentation locally and in docs. - [ ] I have added tests to cover my changes. - [ ] I have ensured that all the checks are passing and green, I've signed the CLA bot
1 parent bdf547f commit 8fbd1d5

File tree

6 files changed

+12
-39
lines changed

6 files changed

+12
-39
lines changed

api/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/gorilla/mux"
99
"github.com/rs/zerolog/log"
1010
"github.com/sprintertech/sprinter-signing/api/handlers"
11+
"github.com/sprintertech/sprinter-signing/health"
1112
)
1213

1314
func Serve(
@@ -23,6 +24,7 @@ func Serve(
2324
r.HandleFunc("/v1/chains/{chainId:[0-9]+}/signatures", signingHandler.HandleSigning).Methods("POST")
2425
r.HandleFunc("/v1/chains/{chainId:[0-9]+}/signatures/{depositId}", statusHandler.HandleRequest).Methods("GET")
2526
r.HandleFunc("/v1/chains/{chainId:[0-9]+}/confirmations", confirmationsHandler.HandleRequest).Methods("GET")
27+
r.HandleFunc("/health", health.HealthHandler()).Methods("GET")
2628

2729
server := &http.Server{
2830
Addr: addr,

app/app.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import (
4242
"github.com/sprintertech/sprinter-signing/comm/elector"
4343
"github.com/sprintertech/sprinter-signing/comm/p2p"
4444
"github.com/sprintertech/sprinter-signing/config"
45-
"github.com/sprintertech/sprinter-signing/health"
4645
"github.com/sprintertech/sprinter-signing/jobs"
4746
"github.com/sprintertech/sprinter-signing/keyshare"
4847
"github.com/sprintertech/sprinter-signing/metrics"
@@ -110,8 +109,6 @@ func Run() error {
110109
panicOnError(err)
111110
log.Info().Str("peerID", host.ID().String()).Msg("Successfully created libp2p host")
112111

113-
go health.StartHealthEndpoint(configuration.RelayerConfig.HealthPort)
114-
115112
communication := p2p.NewCommunication(host, "p2p/sprinter")
116113
electorFactory := elector.NewCoordinatorElectorFactory(host, configuration.RelayerConfig.BullyConfig)
117114
coordinator := tss.NewCoordinator(host, communication, electorFactory)

go.sum

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -950,14 +950,8 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
950950
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
951951
github.com/spf13/viper v1.9.0 h1:yR6EXjTp0y0cLN8OZg1CRZmOBdI88UcGkhgyJhu6nZk=
952952
github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4=
953-
github.com/sprintertech/lifi-solver v0.0.0-20251106144931-4586926e1a4c h1:gt7WBOMG049RFW0E0tq7t5PuaU3utWDgbzzq98iMyug=
954-
github.com/sprintertech/lifi-solver v0.0.0-20251106144931-4586926e1a4c/go.mod h1:3yuTgBKvA5WLCFsXXuBnOzk5nNS58phc881uXLGfD0o=
955-
github.com/sprintertech/lifi-solver v0.0.0-20251107125259-138b58fd00bc h1:h/DY03o7cOez2Ilrwt9TO9BKWIYrAo3o/KvhvEwkziQ=
956-
github.com/sprintertech/lifi-solver v0.0.0-20251107125259-138b58fd00bc/go.mod h1:d5/fytopwudQUE9ojF54XwtqLRFD3JbpBlri7ygb3ng=
957953
github.com/sprintertech/lifi-solver v0.0.0-20251107154632-5c22e7948a82 h1:Nq9wH4wU4W+3UXfeTqGwMBxr+yKDkz0wO6XzpSRkamg=
958954
github.com/sprintertech/lifi-solver v0.0.0-20251107154632-5c22e7948a82/go.mod h1:d5/fytopwudQUE9ojF54XwtqLRFD3JbpBlri7ygb3ng=
959-
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e h1:5sSP6GbqCT/ApxxZmUtav6GHy5Ke98zh5oqQxewhJd4=
960-
github.com/sprintertech/solver-config/go v0.0.0-20251027142430-7f32bdd5da1e/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ=
961955
github.com/sprintertech/solver-config/go v0.0.0-20251107123115-0ea5f862cab9 h1:oo4/4LvkYMVVl/u9+iqEY91iCDFJ05pGwUJNX+6APnA=
962956
github.com/sprintertech/solver-config/go v0.0.0-20251107123115-0ea5f862cab9/go.mod h1:MrIGW6M815PSYKtWSeOd1Z7eiSeOIk/uA/6E2PhlQVQ=
963957
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=

health/health.go

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,12 @@
44
package health
55

66
import (
7-
"fmt"
87
"net/http"
9-
"time"
10-
11-
"github.com/rs/zerolog/log"
128
)
139

14-
// StartHealthEndpoint starts /health endpoint on provided port that returns ok on invocation
15-
func StartHealthEndpoint(port uint16) {
16-
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
10+
// HealthHandler returns a handler function for the /health endpoint
11+
func HealthHandler() http.HandlerFunc {
12+
return func(w http.ResponseWriter, r *http.Request) {
1713
_, _ = w.Write([]byte("ok"))
18-
})
19-
20-
srv := &http.Server{
21-
Addr: fmt.Sprintf(":%d", port),
22-
ReadTimeout: 10 * time.Second,
23-
WriteTimeout: 10 * time.Second,
24-
IdleTimeout: 30 * time.Second,
25-
ReadHeaderTimeout: 2 * time.Second,
2614
}
27-
28-
err := srv.ListenAndServe()
29-
if err != nil {
30-
log.Err(err).Msgf("Failed starting health server")
31-
return
32-
}
33-
34-
log.Info().Msgf("started /health endpoint on port %d", port)
3515
}

tss/ecdsa/common/mock/tss.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tss/mock/ecdsa.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)