Skip to content

Commit

Permalink
health check socket message (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
tigh-latte authored Dec 8, 2021
1 parent 2d0e146 commit c2e3342
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/internal/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func SetupHybrid(cfg config.Config, l log.Logger, e *echo.Echo) *server.SocketSe
p4Handlers.NewPaymentHandler(paymentSvc).RegisterRoutes(g)
p4Handlers.NewPaymentRequestHandler(paymentReqSvc).RegisterRoutes(g)
p4Handlers.NewProofs(proofsSvc).RegisterRoutes(g)
p4soc.NewHealthHandler().Register(s)

e.GET("/ws/:channelID", wsHandler(s))
return s
Expand Down
24 changes: 24 additions & 0 deletions transports/sockets/health.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package sockets

import (
"context"

"github.com/theflyingcodr/sockets"
"github.com/theflyingcodr/sockets/server"
)

type health struct{}

// NewHealthHandler will setup and return a new instance of a health handler.
func NewHealthHandler() *health {
return &health{}
}

// Register will register new handler/s with the socket server.
func (p *health) Register(s *server.SocketServer) {
s.RegisterDirectHandler("health", p.ping)
}

func (p *health) ping(ctx context.Context, msg *sockets.Message) (*sockets.Message, error) {
return msg, nil
}

0 comments on commit c2e3342

Please sign in to comment.