Like Prometheus, but for logs.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
loki/pkg/ingester/instance.go

39 lines
623 B

package ingester
import (
"context"
"sync"
"github.com/grafana/logish/pkg/logproto"
)
type instance struct {
streamsMtx sync.Mutex
streams map[string]*stream
}
func newInstance() *instance {
return &instance{
streams: map[string]*stream{},
}
}
func (i *instance) Push(ctx context.Context, req *logproto.PushRequest) error {
i.streamsMtx.Lock()
defer i.streamsMtx.Unlock()
for _, s := range req.Streams {
stream, ok := i.streams[s.Labels]
if !ok {
stream = newStream()
i.streams[s.Labels] = stream
}
if err := stream.Push(ctx, s.Entries); err != nil {
return err
}
}
return nil
}