mirror of
https://github.com/openziti/zrok.git
synced 2025-02-08 06:20:54 +01:00
better index path configurability (#128)
This commit is contained in:
parent
e4877a20ed
commit
4f33c3d1dd
@ -11,8 +11,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type FileSourceConfig struct {
|
type FileSourceConfig struct {
|
||||||
Path string
|
Path string
|
||||||
DataPath string
|
IndexPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadFileSourceConfig(v interface{}, opts *cf.Options) (interface{}, error) {
|
func loadFileSourceConfig(v interface{}, opts *cf.Options) (interface{}, error) {
|
||||||
@ -38,10 +38,9 @@ func (s *fileSource) Start(events chan map[string]interface{}) (join chan struct
|
|||||||
}
|
}
|
||||||
_ = f.Close()
|
_ = f.Close()
|
||||||
|
|
||||||
idxPath := s.cfg.Path + ".idx"
|
idxF, err := os.OpenFile(s.indexPath(), os.O_CREATE|os.O_RDWR, os.ModePerm)
|
||||||
idxF, err := os.OpenFile(idxPath, os.O_CREATE|os.O_RDWR, os.ModePerm)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error opening '%v'", idxPath)
|
return nil, errors.Wrapf(err, "error opening '%v'", s.indexPath())
|
||||||
}
|
}
|
||||||
|
|
||||||
pos := int64(0)
|
pos := int64(0)
|
||||||
@ -98,3 +97,11 @@ func (s *fileSource) tail(pos int64, events chan map[string]interface{}, idxF *o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *fileSource) indexPath() string {
|
||||||
|
if s.cfg.IndexPath == "" {
|
||||||
|
return s.cfg.Path + ".idx"
|
||||||
|
} else {
|
||||||
|
return s.cfg.IndexPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user