Butcher
A data framework for executing batch task
Install / Use
/learn @KawashiroNitori/ButcherREADME
butcher
Overview
Butcher is a library providing a simple way to execute some task concurrency. Integrates convenient features such as concurrency control and retry.
Quick Start
package main
import (
"context"
"fmt"
"github.com/KawashiroNitori/butcher"
)
type executor struct{}
func (e *executor) GenerateJob(ctx context.Context, jobCh chan<- int) error {
// generate your jobs here
for i := 0; i < 100; i++ {
// you can check canceled context or not, is up to you
select {
case <- ctx.Done():
return nil
default:
}
// push your job into channel
jobCh <- i
}
// you may NOT close jobCh manually
return nil
}
func (e *executor) Task(ctx context.Context, job int) error {
// execute your job here
fmt.Printf("job %v finished!\n", job)
return nil
}
// OnFinish implement an optional func to check your job is finished if you want
func (e *executor) OnFinish(ctx context.Context, job int, err error) {
if err != nil {
fmt.Printf("job %v error: %v", job, err)
}
}
func main() {
ctx := context.Background()
b, err := butcher.NewButcher[int](&executor{}) // you can add some options here
if err != nil {
panic(err)
}
err = b.Run(ctx)
if err != nil {
panic(err)
}
}
Related Skills
node-connect
347.6kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.6kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.6kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
