diff --git a/caching/caching_boltdb.go b/caching/caching_boltdb.go index 08f8d26..3191f2a 100644 --- a/caching/caching_boltdb.go +++ b/caching/caching_boltdb.go @@ -167,26 +167,21 @@ func (c *CachingBolt) getAppFromCache(appGuid string) (*App, error) { } func (c *CachingBolt) getAllAppsFromBoltDB() (map[string]*App, error) { - var allData [][]byte - c.appdb.View(func(tx *bolt.Tx) error { - b := tx.Bucket([]byte(APP_BUCKET)) - b.ForEach(func(guid []byte, v []byte) error { - allData = append(allData, v) + apps := make(map[string]*App) + err := c.appdb.View(func(tx *bolt.Tx) error { + return tx.Bucket([]byte(APP_BUCKET)).ForEach(func(guid []byte, v []byte) error { + var app App + err := json.Unmarshal(v, &app) + if err != nil { + return err + } + apps[app.Guid] = &app return nil }) - return nil }) - - apps := make(map[string]*App, len(allData)) - for i := range allData { - var app App - err := json.Unmarshal(allData[i], &app) - if err != nil { - return nil, err - } - apps[app.Guid] = &app + if err != nil { + return nil, err } - return apps, nil } diff --git a/eventRouting/event_filter.go b/eventRouting/event_filter.go index bf12e45..36f8a80 100644 --- a/eventRouting/event_filter.go +++ b/eventRouting/event_filter.go @@ -12,6 +12,7 @@ type EventFilter func(*fevents.Event) bool //HasIgnoreField Filter out the event has ignored app filed func HasIgnoreField(event *fevents.Event) bool { ignored, hasIgnoredField := event.Fields["cf_ignored_app"] + delete(event.Fields, "cf_ignored_app") return ignored == true && hasIgnoredField }