func InitHandler(
	ctx context.Context,
	raw config.ConfigRaw,
	control config.Control,
) (config.TypeOutputConfig, error) {
	conf := DefaultOutputConfig()
	if err := config.ReflectConfig(raw, &conf); err != nil {
		return nil, err
	}

	if len(conf.Hosts) <= 0 {
		return nil, ErrNoValidHosts
	}

	// host validation regex
	r := regexp.MustCompile(`[^\:]+:[0-9]{1,5}`)

	for _, host := range conf.Hosts {
		if !r.MatchString(host) {
			return nil, ErrInvalidHost
		}

		gelfWriter, err := NewWriter(GELFConfig{
			Host:             host,
			ChunkSize:        conf.ChunkSize,
			CompressionLevel: conf.CompressionLevel,
			CompressionType:  CompressType(conf.CompressionType),
		})
		if err != nil {
			return nil, ErrorCreateClientFailed1.New(err, host)
		}

		conf.gelfWriters = append(conf.gelfWriters, gelfWriter)
	}

	// create the queue
	conf.queue = queue.NewSimpleQueue(ctx, control, &conf, nil, conf.MaxQueueSize, conf.RetryInterval)

	return conf.queue, nil
}
// InitHandler initialize the output plugin
InitHandler initialize the output plugin
// InitHandler initialize the output plugin
func InitHandler(
	ctx context.Context,
	raw config.ConfigRaw,
	control config.Control,
) (config.TypeOutputConfig, error) {
	conf := DefaultOutputConfig()
	if err := config.ReflectConfig(raw, &conf); err != nil {
		return nil, err
	}
	if len(conf.Hosts) <= 0 {
		return nil, ErrNoValidHosts
	}
	r := regexp.MustCompile(`[^\:]+:[0-9]{1,5}`)
	for _, host := range conf.Hosts {
		if !r.MatchString(host) {
			return nil, ErrInvalidHost
		}
		gelfWriter, err := NewWriter(GELFConfig{
			Host:             host,
			ChunkSize:        conf.ChunkSize,
			CompressionLevel: conf.CompressionLevel,
			CompressionType:  CompressType(conf.CompressionType),
		})
		if err != nil {
			return nil, ErrorCreateClientFailed1.New(err, host)
		}
		conf.gelfWriters = append(conf.gelfWriters, gelfWriter)
	}
	conf.queue = queue.NewSimpleQueue(ctx, control, &conf, nil, conf.MaxQueueSize, conf.RetryInterval)
	return conf.queue, nil
}
func InitHandler ( ctx context . Context , raw config . ConfigRaw , control config . Control , ) ( config . TypeOutputConfig , error ) { conf := DefaultOutputConfig ( ) if err := config . ReflectConfig ( raw , & conf ) ; err != nil { return nil , err } if len ( conf . Hosts ) <= 0 { return nil , ErrNoValidHosts } r := regexp . MustCompile ( `[^\:]+:[0-9]{1,5}` ) for _ , host := range conf . Hosts { if ! r . MatchString ( host ) { return nil , ErrInvalidHost } gelfWriter , err := NewWriter ( GELFConfig { Host : host , ChunkSize : conf . ChunkSize , CompressionLevel : conf . CompressionLevel , CompressionType : CompressType ( conf . CompressionType ) , } ) if err != nil { return nil , ErrorCreateClientFailed1 . New ( err , host ) } conf . gelfWriters = append ( conf . gelfWriters , gelfWriter ) } conf . queue = queue . NewSimpleQueue ( ctx , control , & conf , nil , conf . MaxQueueSize , conf . RetryInterval ) return conf . queue , nil }
InitHandler initialize the output plugin
InitHandler initialize the output plugin
// host validation regex // create the queue