runner

package
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package runner は汎用的な並列実行基盤を提供します。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType
	JobIndex  int
	JobName   string
	Status    ResultStatus
	Err       error
	Duration  time.Duration
	Timestamp time.Time
}

Event はジョブ実行中に発火する通知イベントです。

type EventHandler

type EventHandler func(Event)

EventHandler はジョブ実行イベントを受け取るコールバックです。

type EventLogger

type EventLogger struct {
	// contains filtered or unexported fields
}

EventLogger はジョブ実行イベントをファイルに記録します。

func NewEventLogger

func NewEventLogger(path string) (*EventLogger, error)

NewEventLogger は指定パスにログファイルを作成し、EventLogger を返します。

func (*EventLogger) Close

func (l *EventLogger) Close() error

Close はログファイルを閉じます。書き込みエラーがあった場合はそれも報告します。

func (*EventLogger) LogEvent

func (l *EventLogger) LogEvent(event *Event)

LogEvent はイベントを1行のログとしてファイルに書き込みます。

func (*EventLogger) WriteSummary

func (l *EventLogger) WriteSummary(summary Summary)

WriteSummary はログ末尾にサマリーを書き込みます。

type EventType

type EventType string

EventType は実行中に通知されるイベント種別です。

const (
	EventQueued   EventType = "queued"
	EventStarted  EventType = "started"
	EventFinished EventType = "finished"
)

type Job

type Job struct {
	Name string
	Run  func(context.Context) error
}

Job は実行対象のジョブです。

type Result

type Result struct {
	Name     string
	Status   ResultStatus
	Err      error
	Duration time.Duration
}

Result は単一ジョブの実行結果です。

type ResultStatus

type ResultStatus string

ResultStatus はジョブ実行結果の状態です。

const (
	StatusSuccess ResultStatus = "success"
	StatusFailed  ResultStatus = "failed"
	StatusSkipped ResultStatus = "skipped"
)

type Summary

type Summary struct {
	Total   int
	Success int
	Failed  int
	Skipped int
	Results []Result
}

Summary は全ジョブの実行集計です。

func Execute

func Execute(ctx context.Context, maxJobs int, jobs []Job) Summary

Execute はジョブを指定並列数で実行し、結果を返します。

func ExecuteWithEvents

func ExecuteWithEvents(ctx context.Context, maxJobs int, jobs []Job, onEvent EventHandler) Summary

ExecuteWithEvents はジョブを指定並列数で実行し、イベント通知つきで結果を返します。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL