The Flusher plug-in interacts with external systems and sends data to the outside. The following will guide how to develop the Flusher plugin.
Init: Plugin initialization interface, the main function of Flusher is to create links to external resources.
Description: plugin description
IsReady: The plugin system will call this interface to check whether the current flusher can still process more data before calling Flush. If the answer is no, it will wait for a while and try again.
Flush: It is the entry point for the plugin system to submit data to the flusher plugin instance, which is used to output the data to the external system. In order to map to the concept of log service, we added three string parameters, which represent the project/logstore/config to which this flusher instance belongs. More details please see Data Structure And Basic structure.
SetUrgent: Identifies that iLogtail is about to exit, and passes the system status to the specific flusher plugin, so that the flusher plugin can automatically adapt to the system state, such as speeding up the output rate. (SetUrgent is called before Stop method of plugins of other kinds, however, there is no meaningful implementaion yet.)
Stop: Stop the flusher plugin, such as disconnecting the link to interact with external systems.
type Flusher interface {
// Init called for init some system resources, like socket, mutex...
Init(Context) error
// Description returns a one-sentence description on the Input.
Description() string
// IsReady checks if flusher is ready to accept more data.
// @projectName, @logstoreName, @logstoreKey: meta of the corresponding data.
// Note: If SetUrgent is called, please make some adjustment so that IsReady
// can return true to accept more data in time and config instance can be
// stopped gracefully.
IsReady(projectName string, logstoreName string, logstoreKey int64) bool
// Flush flushes data to destination, such as SLS, console, file, etc.
// It is expected to return no error at most time because IsReady will be called
// before it to make sure there is space for next data.
Flush(projectName string, logstoreName string, configName string, logGroupList []*protocol.LogGroup) error
// SetUrgent indicates the flusher that it will be destroyed soon.
// @flag indicates if main program (Logtail mostly) will exit after calling this.
//
// Note: there might be more data to flush after SetUrgent is called, and if flag
// is true, these data will be passed to flusher through IsReady/Flush before
// program exits.
//
// Recommendation: set some state flags in this method to guide the behavior
// of other methods.
SetUrgent(flag bool)
// Stop stops flusher and release resources.
// It is time for flusher to do cleaning jobs, includes:
// 1. Flush cached but not flushed data. For flushers that contain some kinds of
// aggregation or buffering, it is important to flush cached out now, otherwise
// data will lost.
// 2. Release opened resources: goroutines, file handles, connections, etc.
// 3. Maybe more, it depends.
// In a word, flusher should only have things that can be recycled by GC after this.
Stop() error
}
The development of ServiceInput is divided into the following steps:
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )