Documentation
¶
Index ¶
- Variables
- func Reconcile[Key comparable, Input any](logger log.Logger, s *Scheduler[Key], it iter.Seq[Input], ...)
- type DebugSource
- type DefaultLogsResponseWriter
- type HTTPRoute
- type HandlerRoute
- type KeyFn
- type LogsConfig
- type LogsResponseWriter
- type LogsRoute
- type Scheduler
- func (s *Scheduler[Key]) Contains(k Key) bool
- func (s *Scheduler[Key]) Len() int
- func (s *Scheduler[Key]) Reset()
- func (s *Scheduler[Key]) ScheduleSource(source Source[Key])
- func (s *Scheduler[Key]) Sources() iter.Seq[Source[Key]]
- func (s *Scheduler[Key]) Stop()
- func (s *Scheduler[Key]) StopSource(source Source[Key])
- type Server
- type ServerConfig
- type Source
- type SourceFactoryFn
- type SourceWithRetry
Constants ¶
This section is empty.
Variables ¶
var ErrSkip = errors.New("skip source")
ErrSkip is used to indicate that a particular source should not be scheduled.
Functions ¶
func Reconcile ¶
func Reconcile[Key comparable, Input any]( logger log.Logger, s *Scheduler[Key], it iter.Seq[Input], keyFn KeyFn[Key, Input], sourceFactoryFn SourceFactoryFn[Key, Input], )
Reconcile synchronizes the scheduler's set of running sources with a desired state. It iterates over inputs, creates sources for new items, and stops sources that are no longer needed.
Types ¶
type DebugSource ¶
type DebugSource interface {
DebugInfo() any
}
DebugSource is an optional interface with debug information.
type DefaultLogsResponseWriter ¶ added in v1.16.0
type DefaultLogsResponseWriter struct{}
func (DefaultLogsResponseWriter) WriteResponse ¶ added in v1.16.0
func (d DefaultLogsResponseWriter) WriteResponse(w http.ResponseWriter, r *http.Request, status int, err error)
type HandlerRoute ¶ added in v1.16.0
HandlerRoute describes an HTTP endpoint handled directly with an http.Handler.
type KeyFn ¶
type KeyFn[Key comparable, Input any] func(Input) Key
KeyFn extracts a comparable key of type Key from an input value of type Input. The key is used to uniquely identify sources in the scheduler.
type LogsConfig ¶ added in v1.16.0
type LogsResponseWriter ¶ added in v1.16.0
type LogsResponseWriter interface {
WriteResponse(w http.ResponseWriter, r *http.Request, status int, err error)
}
LogsResponseWriter can customize the HTTP response written for a LogsRoute after entries have been forwarded or a request has been rejected.
type LogsRoute ¶ added in v1.16.0
type LogsRoute interface {
HTTPRoute
// Logs converts a request into log entries and an HTTP status code.
// If it returns no entries and a non-nil error, the request is rejected.
// If it returns entries, they are forwarded before the status code is written.
// Returning both entries and an error reports partial success using the returned status.
Logs(r *http.Request, opts *LogsConfig) ([]loki.Entry, int, error)
}
LogsRoute describes an HTTP endpoint that produces log entries.
type Scheduler ¶
type Scheduler[Key comparable] struct { // contains filtered or unexported fields }
Scheduler manages the lifecycle of sources. It is not safe for concurrent use: callers must ensure proper synchronization when accessing or modifying Scheduler and its sources from multiple goroutines.
func NewScheduler ¶
func NewScheduler[Key comparable]() *Scheduler[Key]
func (*Scheduler[Key]) Reset ¶
func (s *Scheduler[Key]) Reset()
Reset will stop all running sources and wait for them to finish and reset Scheduler to a usable state.
func (*Scheduler[Key]) ScheduleSource ¶
ScheduleSource will register and run the provided source in a goroutine. If a source with the same key already exists it will do nothing.
func (*Scheduler[Key]) Stop ¶
func (s *Scheduler[Key]) Stop()
Stop will stop all running sources and wait for them to finish. Scheduler should not be reused after Stop is called.
func (*Scheduler[Key]) StopSource ¶
StopSource will unregister provided source and cancel it without waiting for it to stop.
type Server ¶ added in v1.16.0
type Server struct {
// contains filtered or unexported fields
}
Server exposes HTTP routes that ingest log entries and forward them in batches.
func NewServer ¶ added in v1.16.0
func NewServer(logger log.Logger, reg prometheus.Registerer, recv loki.LogsBatchReceiver, cfg ServerConfig) (*Server, error)
func (*Server) ForceShutdown ¶ added in v1.16.0
func (s *Server) ForceShutdown()
ForceShutdown stops the server without waiting for in-flight requests.
func (*Server) NeedsRestart ¶ added in v1.16.0
func (s *Server) NeedsRestart(netConfig *fnet.ServerConfig) bool
NeedsRestart reports whether a new server instance is required.
func (*Server) Run ¶ added in v1.16.0
func (s *Server) Run(logs []LogsRoute, handlers []HandlerRoute) error
Run registers the configured routes and starts the server.
func (*Server) Update ¶ added in v1.16.0
func (s *Server) Update(logsConfig *LogsConfig)
Update replaces the configuration used for incoming log requests.
type ServerConfig ¶ added in v1.16.0
type ServerConfig struct {
Namespace string
EntriesWritten prometheus.Counter
NetConfig *fnet.ServerConfig
LogsConfig *LogsConfig
}
type Source ¶
type Source[Key comparable] interface { // Run should start the source. // It should run until there is no more work or context is canceled. Run(ctx context.Context) // Key is used to uniquely identify the source. Key() Key }
type SourceFactoryFn ¶
type SourceFactoryFn[Key comparable, Input any] func(Key, Input) (Source[Key], error)
SourceFactoryFn creates a Source[Key] from a key and input value. It returns the created source (or nil if creation failed or should be skipped) and an error. Return ErrSkip to indicate that the source should not be scheduled without logging an error.
type SourceWithRetry ¶
type SourceWithRetry[Key comparable] struct { // contains filtered or unexported fields }
SourceWithRetry is used to wrap another source and apply retries when running.
func NewSourceWithRetry ¶
func NewSourceWithRetry[Key comparable](source Source[Key], config backoff.Config) *SourceWithRetry[Key]
func (*SourceWithRetry[Key]) DebugInfo ¶
func (s *SourceWithRetry[Key]) DebugInfo() any
func (*SourceWithRetry[Key]) Key ¶
func (s *SourceWithRetry[Key]) Key() Key
func (*SourceWithRetry[Key]) Run ¶
func (s *SourceWithRetry[Key]) Run(ctx context.Context)
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
Package kubernetes implements the loki.source.kubernetes component.
|
Package kubernetes implements the loki.source.kubernetes component. |
|
kubetail
Package kubetail implements a log file tailer using the Kubernetes API.
|
Package kubetail implements a log file tailer using the Kubernetes API. |
|
Package kubernetes_events implements the loki.source.kubernetes_events component.
|
Package kubernetes_events implements the loki.source.kubernetes_events component. |
|
win_eventlog
Package win_eventlog Input plugin to collect Windows Event Log messages
|
Package win_eventlog Input plugin to collect Windows Event Log messages |