add some todo's

This commit is contained in:
Sergey Chubaryan 2024-08-25 03:50:55 +03:00
parent 69e24ec8ba
commit 717a923dff
4 changed files with 9 additions and 1 deletions

View File

@ -39,7 +39,7 @@ func (a *App) Run(p RunParams) {
ctx = p.Ctx ctx = p.Ctx
osArgs = p.OsArgs osArgs = p.OsArgs
_ = p.EnvVars _ = p.EnvVars
debugMode = false // TODO: replace to flag from conf debugMode = false // TODO: replace with flag from conf
) )
//----------------------------------------- //-----------------------------------------

View File

@ -120,6 +120,7 @@ func (c charsetUnion) RandomRune(r RandInt) rune {
} }
func (c charsetUnion) RandomString(r RandInt, size int) string { func (c charsetUnion) RandomString(r RandInt, size int) string {
// TODO: improve distribution
builder := strings.Builder{} builder := strings.Builder{}
for i := 0; i < size; i++ { for i := 0; i < size; i++ {
index := r.Int() % (len(c.charsets) - 1) index := r.Int() % (len(c.charsets) - 1)

View File

@ -11,6 +11,7 @@ type bufioWrapper struct {
} }
func (b *bufioWrapper) Write(p []byte) (nn int, err error) { func (b *bufioWrapper) Write(p []byte) (nn int, err error) {
// TODO: try replace mutex, improve logging perfomance
b.m.RLock() b.m.RLock()
defer b.m.RUnlock() defer b.m.RUnlock()

View File

@ -26,6 +26,7 @@ type NewLoggerOpts struct {
} }
func New(opts NewLoggerOpts) (Logger, error) { func New(opts NewLoggerOpts) (Logger, error) {
// TODO: pass output streams from opts
writers := []io.Writer{} writers := []io.Writer{}
writers = append(writers, os.Stderr) writers = append(writers, os.Stderr)
@ -37,14 +38,19 @@ func New(opts NewLoggerOpts) (Logger, error) {
writers = append(writers, file) writers = append(writers, file)
} }
// TODO: more log levels
level := zerolog.TraceLevel level := zerolog.TraceLevel
if opts.Debug { if opts.Debug {
level = zerolog.DebugLevel level = zerolog.DebugLevel
} }
// TODO: move to wrapper, determine optimal buffer size
writer := bufio.NewWriterSize(io.MultiWriter(writers...), 8*1024) writer := bufio.NewWriterSize(io.MultiWriter(writers...), 8*1024)
wrapper := &bufioWrapper{writer, &sync.RWMutex{}} wrapper := &bufioWrapper{writer, &sync.RWMutex{}}
// Periodically flush buffer
go func() { go func() {
// TODO: add cooldown if flush was triggered by overfow
tmr := time.NewTicker(500 * time.Millisecond) tmr := time.NewTicker(500 * time.Millisecond)
defer tmr.Stop() defer tmr.Stop()