package worker import ( "context" "github.com/valyala/fasthttp" ) type ServerWorker struct { server *fasthttp.Server } func (self *ServerWorker) Start(ctx context.Context) error { go func() { // nolint: errcheck self.server.ListenAndServe("0.0.0.0:8080") }() <-ctx.Done() return self.Shutdown() } func (self *ServerWorker) Shutdown() error { return self.server.Shutdown() } func NewServerWorker(server *fasthttp.Server) *ServerWorker { return &ServerWorker{ server: server, } }