{"modulePath":"github.com/DoNewsCode/core-processor","version":"v0.2.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package processor\n\n## Functions\n\n```go\nfunc IsFatalErr(err error) bool\n```\n\n```go\nfunc NewFatalErr(err error) error\n```\nNewFatalErr wrap original err to create FatalErr\n\n## Types\n\n```go\ntype BatchFunc func(ctx context.Context, data []interface{}) error\n```\nBatchFunc type for BatchHandler.Batch Func.\n\n```go\ntype BatchHandler interface {\n\tHandler\n\t// Batch processing the results returned by Handler.Handle.\n\tBatch(ctx context.Context, data []interface{}) error\n}\n```\nBatchHandler one more Batch method than Handler.\n\n```go\ntype FatalErr interface {\n\tFatal() bool\n}\n```\nFatalErr raise this error to exist processor\n\n```go\ntype HandleFunc func(ctx context.Context, msg *kafka.Message) (interface{}, error)\n```\nHandleFunc type for Handler.Handle Func.\n\n```go\ntype Handler interface {\n\t// Info set the topic name and some config.\n\tInfo() *Info\n\t// Handle for *kafka.Message.\n\tHandle(ctx context.Context, msg *kafka.Message) (interface{}, error)\n}\n```\nHandler only include Info and Handle func.\n\n```go\ntype Info struct {\n\t// used to get reader from otkafka.ReaderMaker.\n\t// default: \"default\"\n\tName string\n\t// reader workers count.\n\t// default: 1\n\tReadWorker int\n\t// batch workers count.\n\t// default: 1\n\tBatchWorker int\n\t// data size for batch processing.\n\t// default: 1\n\tBatchSize int\n\t// handler workers count.\n\tHandleWorker int\n\t// the size of the data channel.\n\t// default: 100\n\tChanSize int\n\t// run the batchFunc automatically at specified intervals, avoid not executing without reaching BatchSize\n\t// default: 30s\n\tAutoBatchInterval time.Duration\n}\n```\nInfo the info of BatchHandler.\n\nNote:\n\n\tIf sequence is necessary, make sure that per worker count is one.\n\tMultiple goroutines cannot guarantee the order in which data is processed.\n\n```go\ntype Out struct {\n\tdi.Out\n\n\tHandlers []Handler `group:\"ProcessorHandler,flatten\"`\n}\n```\nOut to provide Handler to in.Handlers.\n\n```go\nfunc NewOut(handlers ...Handler) Out\n```\nNewOut create Out to provide Handler to in.Handlers.\n\n\tUsage:\n\t\tfunc newHandlerA(logger log.Logger) processor.Out {\n\t\t\treturn processor.NewOut(\n\t\t\t\t\u0026HandlerA{logger: logger},\n\t\t\t)\n\t\t}\n\tOr\n\t\tfunc newHandlers(logger log.Logger) processor.Out {\n\t\t\treturn processor.NewOut(\n\t\t\t\t\u0026HandlerA{logger: logger},\n\t\t\t\t\u0026HandlerB{logger: logger},\n\t\t\t)\n\t\t}\n\n```go\ntype Processor struct {\n\t// contains filtered or unexported fields\n}\n```\nProcessor dispatch Handler.\n\n```go\nfunc New(i in) (*Processor, error)\n```\nNew create \\*Processor Module.\n\n```go\nfunc (e *Processor) ProvideRunGroup(group *run.Group)\n```\nProvideRunGroup run workers:\n\n 1. Fetch message from \\*kafka.Reader.\n 2. Handle message by Handler.Handle.\n 3. Batch data by BatchHandler.Batch. If batch success then commit message.\n\n","path":"github.com/DoNewsCode/core-processor","name":"processor","synopsis":"","isRedistributable":true}
