github.com/Jeffail/benthos/v3@v3.65.0/public/service/plugins.go (about)

     1  package service
     2  
     3  // BatchBufferConstructor is a func that's provided a configuration type and
     4  // access to a service manager and must return an instantiation of a buffer
     5  // based on the config, or an error.
     6  //
     7  // Consumed message batches must be created by upstream components (inputs, etc)
     8  // otherwise this buffer will simply receive batches containing single messages.
     9  type BatchBufferConstructor func(conf *ParsedConfig, mgr *Resources) (BatchBuffer, error)
    10  
    11  // RegisterBatchBuffer attempts to register a new buffer plugin by providing a
    12  // description of the configuration for the buffer and a constructor for the
    13  // buffer processor. The constructor will be called for each instantiation of
    14  // the component within a config.
    15  //
    16  // Consumed message batches must be created by upstream components (inputs, etc)
    17  // otherwise this buffer will simply receive batches containing single
    18  // messages.
    19  func RegisterBatchBuffer(name string, spec *ConfigSpec, ctor BatchBufferConstructor) error {
    20  	return globalEnvironment.RegisterBatchBuffer(name, spec, ctor)
    21  }
    22  
    23  // CacheConstructor is a func that's provided a configuration type and access to
    24  // a service manager and must return an instantiation of a cache based on the
    25  // config, or an error.
    26  type CacheConstructor func(conf *ParsedConfig, mgr *Resources) (Cache, error)
    27  
    28  // RegisterCache attempts to register a new cache plugin by providing a
    29  // description of the configuration for the plugin as well as a constructor for
    30  // the cache itself. The constructor will be called for each instantiation of
    31  // the component within a config.
    32  func RegisterCache(name string, spec *ConfigSpec, ctor CacheConstructor) error {
    33  	return globalEnvironment.RegisterCache(name, spec, ctor)
    34  }
    35  
    36  // InputConstructor is a func that's provided a configuration type and access to
    37  // a service manager, and must return an instantiation of a reader based on the
    38  // config, or an error.
    39  type InputConstructor func(conf *ParsedConfig, mgr *Resources) (Input, error)
    40  
    41  // RegisterInput attempts to register a new input plugin by providing a
    42  // description of the configuration for the plugin as well as a constructor for
    43  // the input itself. The constructor will be called for each instantiation of
    44  // the component within a config.
    45  //
    46  // If your input implementation doesn't have a specific mechanism for dealing
    47  // with a nack (when the AckFunc provides a non-nil error) then you can instead
    48  // wrap your input implementation with AutoRetryNacks to get automatic retries.
    49  func RegisterInput(name string, spec *ConfigSpec, ctor InputConstructor) error {
    50  	return globalEnvironment.RegisterInput(name, spec, ctor)
    51  }
    52  
    53  // BatchInputConstructor is a func that's provided a configuration type and
    54  // access to a service manager, and must return an instantiation of a batched
    55  // reader based on the config, or an error.
    56  type BatchInputConstructor func(conf *ParsedConfig, mgr *Resources) (BatchInput, error)
    57  
    58  // RegisterBatchInput attempts to register a new batched input plugin by
    59  // providing a description of the configuration for the plugin as well as a
    60  // constructor for the input itself. The constructor will be called for each
    61  // instantiation of the component within a config.
    62  //
    63  // If your input implementation doesn't have a specific mechanism for dealing
    64  // with a nack (when the AckFunc provides a non-nil error) then you can instead
    65  // wrap your input implementation with AutoRetryNacksBatched to get automatic
    66  // retries.
    67  func RegisterBatchInput(name string, spec *ConfigSpec, ctor BatchInputConstructor) error {
    68  	return globalEnvironment.RegisterBatchInput(name, spec, ctor)
    69  }
    70  
    71  // OutputConstructor is a func that's provided a configuration type and access
    72  // to a service manager, and must return an instantiation of a writer based on
    73  // the config and a maximum number of in-flight messages to allow, or an error.
    74  type OutputConstructor func(conf *ParsedConfig, mgr *Resources) (out Output, maxInFlight int, err error)
    75  
    76  // RegisterOutput attempts to register a new output plugin by providing a
    77  // description of the configuration for the plugin as well as a constructor for
    78  // the output itself. The constructor will be called for each instantiation of
    79  // the component within a config.
    80  func RegisterOutput(name string, spec *ConfigSpec, ctor OutputConstructor) error {
    81  	return globalEnvironment.RegisterOutput(name, spec, ctor)
    82  }
    83  
    84  // BatchOutputConstructor is a func that's provided a configuration type and
    85  // access to a service manager, and must return an instantiation of a writer
    86  // based on the config, a batching policy, and a maximum number of in-flight
    87  // message batches to allow, or an error.
    88  type BatchOutputConstructor func(conf *ParsedConfig, mgr *Resources) (out BatchOutput, batchPolicy BatchPolicy, maxInFlight int, err error)
    89  
    90  // RegisterBatchOutput attempts to register a new output plugin by providing a
    91  // description of the configuration for the plugin as well as a constructor for
    92  // the output itself. The constructor will be called for each instantiation of
    93  // the component within a config.
    94  //
    95  // The constructor of a batch output is able to return a batch policy to be
    96  // applied before calls to write are made, creating batches from the stream of
    97  // messages. However, batches can also be created by upstream components
    98  // (inputs, buffers, etc).
    99  //
   100  // If a batch has been formed upstream it is possible that its size may exceed
   101  // the policy specified in your constructor.
   102  func RegisterBatchOutput(name string, spec *ConfigSpec, ctor BatchOutputConstructor) error {
   103  	return globalEnvironment.RegisterBatchOutput(name, spec, ctor)
   104  }
   105  
   106  // ProcessorConstructor is a func that's provided a configuration type and
   107  // access to a service manager and must return an instantiation of a processor
   108  // based on the config, or an error.
   109  type ProcessorConstructor func(conf *ParsedConfig, mgr *Resources) (Processor, error)
   110  
   111  // RegisterProcessor attempts to register a new processor plugin by providing
   112  // a description of the configuration for the processor and a constructor for
   113  // the processor itself. The constructor will be called for each instantiation
   114  // of the component within a config.
   115  //
   116  // For simple transformations consider implementing a Bloblang plugin method
   117  // instead.
   118  func RegisterProcessor(name string, spec *ConfigSpec, ctor ProcessorConstructor) error {
   119  	return globalEnvironment.RegisterProcessor(name, spec, ctor)
   120  }
   121  
   122  // BatchProcessorConstructor is a func that's provided a configuration type and
   123  // access to a service manager and must return an instantiation of a processor
   124  // based on the config, or an error.
   125  //
   126  // Message batches must be created by upstream components (inputs, buffers, etc)
   127  // otherwise this processor will simply receive batches containing single
   128  // messages.
   129  type BatchProcessorConstructor func(conf *ParsedConfig, mgr *Resources) (BatchProcessor, error)
   130  
   131  // RegisterBatchProcessor attempts to register a new processor plugin by
   132  // providing a description of the configuration for the processor and a
   133  // constructor for the processor itself. The constructor will be called for each
   134  // instantiation of the component within a config.
   135  func RegisterBatchProcessor(name string, spec *ConfigSpec, ctor BatchProcessorConstructor) error {
   136  	return globalEnvironment.RegisterBatchProcessor(name, spec, ctor)
   137  }
   138  
   139  // RateLimitConstructor is a func that's provided a configuration type and
   140  // access to a service manager and must return an instantiation of a rate limit
   141  // based on the config, or an error.
   142  type RateLimitConstructor func(conf *ParsedConfig, mgr *Resources) (RateLimit, error)
   143  
   144  // RegisterRateLimit attempts to register a new rate limit plugin by providing
   145  // a description of the configuration for the plugin as well as a constructor
   146  // for the rate limit itself. The constructor will be called for each
   147  // instantiation of the component within a config.
   148  func RegisterRateLimit(name string, spec *ConfigSpec, ctor RateLimitConstructor) error {
   149  	return globalEnvironment.RegisterRateLimit(name, spec, ctor)
   150  }