|
|
@@ -54,7 +54,7 @@ type ProjectBackfeedManager struct { |
|
|
|
BackfeedRedis *redis.ClusterClient |
|
|
|
ProjectRedis *redis.Client |
|
|
|
LegacyRedis *redis.Client |
|
|
|
Lock sync.RWMutex |
|
|
|
//Lock sync.RWMutex |
|
|
|
ProjectConfig ProjectConfig |
|
|
|
} |
|
|
|
|
|
|
@@ -66,11 +66,11 @@ func (that *ProjectBackfeedManager) RedisConfigDiffers(new *ProjectRedisConfig) |
|
|
|
} |
|
|
|
|
|
|
|
func (that *ProjectBackfeedManager) PushItem(ctx context.Context, item *BackfeedItem) bool { |
|
|
|
that.Lock.RLock() |
|
|
|
defer that.Lock.RUnlock() |
|
|
|
if that.C == nil { |
|
|
|
return false |
|
|
|
} |
|
|
|
//that.Lock.RLock() |
|
|
|
//defer that.Lock.RUnlock() |
|
|
|
//if that.C == nil { |
|
|
|
// return false |
|
|
|
//} |
|
|
|
select { |
|
|
|
case <-ctx.Done(): |
|
|
|
return false |
|
|
@@ -101,19 +101,20 @@ func (that *ProjectBackfeedManager) PopItem(blocking bool) (*BackfeedItem, bool) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func (that *ProjectBackfeedManager) CloseItemChannel() { |
|
|
|
that.Lock.Lock() |
|
|
|
defer that.Lock.Unlock() |
|
|
|
if that.C == nil { |
|
|
|
return |
|
|
|
} |
|
|
|
close(that.C) |
|
|
|
that.C = nil |
|
|
|
} |
|
|
|
//func (that *ProjectBackfeedManager) CloseItemChannel() { |
|
|
|
// log.Printf("closing item channel for %s", that.Name) |
|
|
|
// that.Lock.Lock() |
|
|
|
// defer that.Lock.Unlock() |
|
|
|
// if that.C == nil { |
|
|
|
// return |
|
|
|
// } |
|
|
|
// close(that.C) |
|
|
|
// that.C = nil |
|
|
|
//} |
|
|
|
|
|
|
|
func (that *ProjectBackfeedManager) Do() { |
|
|
|
defer close(that.Done) |
|
|
|
defer that.CloseItemChannel() |
|
|
|
//defer that.CloseItemChannel() |
|
|
|
defer that.Cancel() |
|
|
|
|
|
|
|
for { |
|
|
|