mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
converted to pilosa.logger
This commit is contained in:
parent
1706e9b4e1
commit
a0dda250a5
1 changed files with 12 additions and 4 deletions
16
translate.go
16
translate.go
|
|
@ -69,7 +69,7 @@ type TranslateFile struct {
|
|||
|
||||
Path string
|
||||
mapSize int
|
||||
|
||||
logger Logger
|
||||
// If non-nil, data is streamed from a primary and this is a read-only store.
|
||||
PrimaryTranslateStore TranslateStore
|
||||
primaryID string // unique ID used to identify the primary store
|
||||
|
|
@ -90,6 +90,12 @@ func OptTranslateFileMapSize(mapSize int) TranslateFileOption {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
func OptTranslateFileLogger(l Logger) TranslateFileOption {
|
||||
return func(s *TranslateFile) error {
|
||||
s.logger = l
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewTranslateFile returns a new instance of TranslateFile.
|
||||
func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile {
|
||||
|
|
@ -111,6 +117,8 @@ func NewTranslateFile(opts ...TranslateFileOption) *TranslateFile {
|
|||
|
||||
mapSize: defaultMapSize,
|
||||
|
||||
logger: NopLogger,
|
||||
|
||||
replicationClosing: make(chan struct{}),
|
||||
primaryStoreEvents: make(chan primaryStoreEvent),
|
||||
|
||||
|
|
@ -187,12 +195,12 @@ func (s *TranslateFile) handlePrimaryStoreEvent(ev primaryStoreEvent) error {
|
|||
}
|
||||
|
||||
// Stop translate store replication.
|
||||
log.Printf("stop monitor replication")
|
||||
s.logger.Printf("stop monitor replication")
|
||||
close(s.replicationClosing)
|
||||
s.repWG.Wait()
|
||||
|
||||
// Set the primary node for translate store replication.
|
||||
log.Printf("set primary translate store to %s", ev.id)
|
||||
s.logger.Printf("set primary translate store to %s", ev.id)
|
||||
s.primaryID = ev.id
|
||||
if ev.id == "" {
|
||||
s.PrimaryTranslateStore = nil
|
||||
|
|
@ -201,7 +209,7 @@ func (s *TranslateFile) handlePrimaryStoreEvent(ev primaryStoreEvent) error {
|
|||
}
|
||||
|
||||
// Start translate store replication. Stream from primary, if available.
|
||||
log.Printf("start monitor replication")
|
||||
s.logger.Printf("start monitor replication")
|
||||
if s.PrimaryTranslateStore != nil {
|
||||
s.replicationClosing = make(chan struct{})
|
||||
s.repWG.Add(1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue