lens @ d6cf67b3d7747b6274d92e394d75d348060fa5f5

 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}