소스 검색

Correct initialization of antireplay cache

tags/1.0^2
9seconds 6 년 전
부모
커밋
029245cd16
2개의 변경된 파일5개의 추가작업 그리고 10개의 파일을 삭제
  1. 4
    7
      antireplay/cache.go
  2. 1
    3
      cli/proxy.go

+ 4
- 7
antireplay/cache.go 파일 보기

1
 package antireplay
1
 package antireplay
2
 
2
 
3
 import (
3
 import (
4
-	"errors"
5
-	"fmt"
6
-
7
 	"github.com/allegro/bigcache"
4
 	"github.com/allegro/bigcache"
8
 
5
 
9
 	"github.com/9seconds/mtg/config"
6
 	"github.com/9seconds/mtg/config"
20
 	return err == nil
17
 	return err == nil
21
 }
18
 }
22
 
19
 
23
-func Init() error {
20
+func Init() {
24
 	c, err := bigcache.NewBigCache(bigcache.Config{
21
 	c, err := bigcache.NewBigCache(bigcache.Config{
25
 		Shards:           1024,
22
 		Shards:           1024,
26
 		LifeWindow:       config.C.AntiReplay.EvictionTime,
23
 		LifeWindow:       config.C.AntiReplay.EvictionTime,
27
 		Hasher:           hasher{},
24
 		Hasher:           hasher{},
28
 		HardMaxCacheSize: config.C.AntiReplay.MaxSize,
25
 		HardMaxCacheSize: config.C.AntiReplay.MaxSize,
29
 	})
26
 	})
27
+	if err != nil {
28
+		panic(err)
29
+	}
30
 	cache = c
30
 	cache = c
31
-	err = fmt.Errorf("qqq: %w", errors.New("tt"))
32
-
33
-	return err
34
 }
31
 }

+ 1
- 3
cli/proxy.go 파일 보기

60
 
60
 
61
 	PrintJSONStdout(config.GetURLs())
61
 	PrintJSONStdout(config.GetURLs())
62
 
62
 
63
-	if err := antireplay.Init(); err != nil {
64
-		Fatal(err)
65
-	}
63
+	antireplay.Init()
66
 	if err := stats.Init(ctx); err != nil {
64
 	if err := stats.Init(ctx); err != nil {
67
 		Fatal(err)
65
 		Fatal(err)
68
 	}
66
 	}

Loading…
취소
저장