feat: remove un-necessary dependencies

This commit is contained in:
sujit
2024-10-14 22:21:53 +05:45
parent fb3be07d6b
commit aa0cecf1fe
10 changed files with 185 additions and 42 deletions

11
ctx.go
View File

@@ -11,9 +11,10 @@ import (
"time"
"github.com/oarkflow/xid"
"github.com/oarkflow/xsync"
"github.com/oarkflow/mq/consts"
"github.com/oarkflow/mq/storage"
"github.com/oarkflow/mq/storage/memory"
)
type Task struct {
@@ -41,7 +42,7 @@ func IsClosed(conn net.Conn) bool {
func SetHeaders(ctx context.Context, headers map[string]string) context.Context {
hd, _ := GetHeaders(ctx)
if hd == nil {
hd = xsync.NewMap[string, string]()
hd = memory.New[string, string]()
}
for key, val := range headers {
hd.Set(key, val)
@@ -52,7 +53,7 @@ func SetHeaders(ctx context.Context, headers map[string]string) context.Context
func WithHeaders(ctx context.Context, headers map[string]string) map[string]string {
hd, _ := GetHeaders(ctx)
if hd == nil {
hd = xsync.NewMap[string, string]()
hd = memory.New[string, string]()
}
for key, val := range headers {
hd.Set(key, val)
@@ -60,8 +61,8 @@ func WithHeaders(ctx context.Context, headers map[string]string) map[string]stri
return hd.AsMap()
}
func GetHeaders(ctx context.Context) (xsync.IMap[string, string], bool) {
headers, ok := ctx.Value(consts.HeaderKey).(xsync.IMap[string, string])
func GetHeaders(ctx context.Context) (storage.IMap[string, string], bool) {
headers, ok := ctx.Value(consts.HeaderKey).(storage.IMap[string, string])
return headers, ok
}