Skip to content

Commit

Permalink
fix haoquote崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Oct 16, 2023
1 parent ef1303b commit 41323b0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/haoquote/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func main() {

rc := app.RedisInit()
ctext := context.Background()
haoquote.Start(&ctext, rc, db)
haoquote.Run(&ctext, rc, db)
return nil
},
}
Expand Down
4 changes: 3 additions & 1 deletion haoquote/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"github.com/spf13/viper"
"github.com/yzimhao/trading_engine/haoquote/tradelog"
"github.com/yzimhao/trading_engine/haoquote/www"
"github.com/yzimhao/trading_engine/utils/filecache"
"xorm.io/xorm"
)

func Start(ctx *context.Context, rc *redis.Client, db *xorm.Engine) {
func Run(ctx *context.Context, rc *redis.Client, db *xorm.Engine) {
wg := sync.WaitGroup{}
wg.Add(1)
init_symbols_quote()
Expand All @@ -24,6 +25,7 @@ func Start(ctx *context.Context, rc *redis.Client, db *xorm.Engine) {

func init_symbols_quote() {
symbols := viper.GetStringMap("symbol")
filecache.NewStorage(viper.GetString("haoquote.storage_path"), 1)

for k, attr := range symbols {
symbol := strings.ToLower(k)
Expand Down
2 changes: 1 addition & 1 deletion haoquote/period/period_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (c periodCachekey) Format(pt PeriodType, symbol string, st, et int64) strin
}

func newCache() *filecache.Storage {
return filecache.NewStorage(viper.GetString("haoquote.storage_path"), 10)
return filecache.NewStorage(viper.GetString("haoquote.storage_path"), 1)
}

func GetYesterdayClose(symbol string) (string, bool) {
Expand Down
1 change: 0 additions & 1 deletion utils/filecache/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type Storage struct {
var obj *Storage

func NewStorage(filename string, timeout time.Duration) *Storage {

if obj == nil {
db, err := bolt.Open(filename, 0600, &bolt.Options{Timeout: timeout * time.Second})
if err != nil {
Expand Down

0 comments on commit 41323b0

Please sign in to comment.