github.com/Jeffail/benthos/v3@v3.65.0/public/service/package.go (about) 1 // Package service provides a high level API for registering custom plugin 2 // components and executing either a standard Benthos CLI, or programmatically 3 // building isolated pipelines with a StreamBuilder API. 4 // 5 // For a video guide on Benthos plugins check out: https://youtu.be/uH6mKw-Ly0g 6 // And an example repo containing component plugins and tests can be found at: 7 // https://github.com/benthosdev/benthos-plugin-example 8 // 9 // In order to add custom Bloblang functions and methods use the 10 // ./public/bloblang package. 11 package service 12 13 import ( 14 "context" 15 "errors" 16 ) 17 18 var ( 19 // ErrNotConnected is returned by inputs and outputs when their Read or 20 // Write methods are called and the connection that they maintain is lost. 21 // This error prompts the upstream component to call Connect until the 22 // connection is re-established. 23 ErrNotConnected = errors.New("not connected") 24 25 // ErrEndOfInput is returned by inputs that have exhausted their source of 26 // data to the point where subsequent Read calls will be ineffective. This 27 // error prompts the upstream component to gracefully terminate the 28 // pipeline. 29 ErrEndOfInput = errors.New("end of input") 30 31 // ErrEndOfBuffer is returned by a buffer Read/ReadBatch method when the 32 // contents of the buffer has been emptied and the source of the data is 33 // ended (as indicated by EndOfInput). This error prompts the upstream 34 // component to gracefully terminate the pipeline. 35 ErrEndOfBuffer = errors.New("end of buffer") 36 ) 37 38 // Closer is implemented by components that support stopping and cleaning up 39 // their underlying resources. 40 type Closer interface { 41 // Close the component, blocks until either the underlying resources are 42 // cleaned up or the context is cancelled. Returns an error if the context 43 // is cancelled. 44 Close(ctx context.Context) error 45 }