Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package windex | ||
|
||
import( | ||
import ( | ||
"errors" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
package windex | ||
|
||
type Indexer interface { | ||
Parse() error | ||
Flush() error | ||
Parse() error | ||
Flush() error | ||
} | ||
|
||
type StdoutIndexer struct { | ||
|
||
} | ||
|
||
func (i *Indexer) Parse() (err error) { | ||
|
||
func (i *StdoutIndexer) Parse() (err error) { | ||
return | ||
} | ||
|
||
func (i *Indexer) Flush() (err error) { | ||
|
||
func (i *StdoutIndexer) Flush() (err error) { | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
package windex | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
type Windex struct { | ||
watcher *Watcher | ||
logfile *LogFile | ||
indexer *Indexer | ||
logchan chan []byte | ||
logfile *LogFile | ||
watcher *Watcher | ||
indexer *Indexer | ||
log_to_index chan []byte | ||
exit chan bool | ||
} | ||
|
||
/* | ||
watched_index, err = windex.New("logfile01.log") | ||
watched_index.Watch() | ||
watched_index.Index() | ||
windex, err = windex.New("logfile01.log") | ||
err = windex.Watch() | ||
err = windex.Index() | ||
// or .Index(StdoutIndex) where StdoutIndex implements | ||
// Index interface | ||
exit <- windex.exit | ||
Windex methods orchestrate between logfile and indexer, | ||
getting signals from watcher to know when to act | ||
[]byte channel between logfile and indexer | ||
bool channel between windex and the outside world | ||
*/ | ||
func New(filename string) (windex *Windex, err error) { | ||
Watcher *fsnotify.Watcher | ||
|
||
if err != nil { | ||
logfile, err := NewLogFile(filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
defer file.Close() | ||
|
||
watcher, err := fsnotify.NewWatcher() | ||
watcher, err := NewWatcher() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
logfile := &LogFile{} | ||
return &Windex{ | ||
logfile: logfile, | ||
watcher: watcher, | ||
}, nil | ||
} | ||
|
||
if err = log.updateFileSize(); err != nil { | ||
return nil, err | ||
} | ||
func (windex *Windex) Watch() (err error) { | ||
|
||
return log, nil | ||
} | ||
|
||
func (windex *Windex) Index() (err error) { | ||
|
||
} |