lens @ 398ae343e6a33fb81f82380b17081b8f9bae328a

 1package worker
 2
 3import (
 4	"context"
 5
 6	"github.com/valyala/fasthttp"
 7)
 8
 9type ServerWorker struct {
10	server *fasthttp.Server
11}
12
13func (self *ServerWorker) Start(ctx context.Context) error {
14	go func() {
15		// nolint: errcheck
16		self.server.ListenAndServe("0.0.0.0:8080")
17	}()
18
19	<-ctx.Done()
20	return self.Shutdown()
21}
22
23func (self *ServerWorker) Shutdown() error {
24	return self.server.Shutdown()
25}
26
27func NewServerWorker(server *fasthttp.Server) *ServerWorker {
28	return &ServerWorker{
29		server: server,
30	}
31}