mirror of
https://github.com/Xevion/banner.git
synced 2025-12-15 04:11:11 -06:00
feat: proper context handeling, graceful cancellation & shutdown
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
type Config struct {
|
||||
Ctx context.Context
|
||||
CancelFunc context.CancelFunc
|
||||
KV *redis.Client
|
||||
Client *http.Client
|
||||
IsDevelopment bool
|
||||
@@ -23,15 +24,17 @@ const (
|
||||
)
|
||||
|
||||
func New() (*Config, error) {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
loc, err := time.LoadLocation(CentralTimezoneName)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Config{
|
||||
Ctx: ctx,
|
||||
CancelFunc: cancel,
|
||||
CentralTimeLocation: loc,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user