Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extension ¶
type Extension struct { CreateSchemaHandler schemahandler.CreateFunc CreateSchemaHandlerParams interface{} CustomFuncs customfuncs.CustomFuncs }
Extension allows user of omniparser to add new schema handlers, and/or new custom functions in addition to the builtin handlers and functions.
type Schema ¶
type Schema interface { NewTransform(name string, input io.Reader, ctx *transformctx.Ctx) (Transform, error) Header() header.Header Content() []byte }
Schema is an interface that represents an schema used by omniparser. One instance of Schema is associated with one and only one schema. The instance of Schema can be reused for ingesting and transforming multiple input files/streams, as long as they are all intended for the same schema. Each ingestion/transform, however, needs a separate instance of Transform. A Transform must not be shared and reused across different input files/streams. While the same instance of Schema can be shared across multiple threads, Transform is not multi-thread safe. All operations on it must be done within the same go routine.
func NewSchema ¶
NewSchema creates a new instance of Schema. Caller can use the optional Extensions for customization. NewSchema will scan through exts left to right to find the first extension with a schema handler (specified by CreateSchemaHandler field) that supports the input schema. If no ext provided or no ext with a handler that supports the schema, then NewSchema will fall back to builtin extension (currently for schema version 'omni.2.1'. If the input schema is still not supported by builtin extension, NewSchema will fail with ErrSchemaNotSupported. Each extension much be fully self-contained meaning all the custom functions it intends to use in the schemas supported by it must be included in the same extension.
type Transform ¶
type Transform interface { // Read returns a JSON byte slice representing one ingested and transformed record. // io.EOF should be returned when input stream is completely consumed and future calls // to Read should always return io.EOF. // errs.ErrTransformFailed should be returned when a record ingestion and transformation // failed and such failure isn't considered fatal. Future calls to Read will attempt // new record ingestion and transformations. // Any other error returned is considered fatal and future calls to Read will always // return the same error. // Note if returned error isn't nil, then returned []byte will be nil. Read() ([]byte, error) // RawRecord returns the current raw record ingested from the input stream. If the last // Read call failed, or Read hasn't been called yet, it will return an error. RawRecord() (schemahandler.RawRecord, error) }
Transform is an interface that represents one input stream ingestion and transform operation. An instance of a Transform must not be shared and reused among different input streams. An instance of a Transform must not be used across multiple goroutines.