types

package
v3.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJobID

func GenerateJobID(partition int32, offsets Offsets) string

GenerateJobID creates a deterministic job ID from partition and offsets

func NewSchedulerServer

func NewSchedulerServer(handler SchedulerHandler) proto.SchedulerServiceServer

NewSchedulerServer creates a new gRPC server that delegates to the provided handler

Types

type BuilderTransport

type BuilderTransport interface {
	// SendGetJobRequest sends a request to get a new job
	SendGetJobRequest(ctx context.Context, req *GetJobRequest) (*GetJobResponse, error)
	// SendCompleteJob sends a job completion notification
	SendCompleteJob(ctx context.Context, req *CompleteJobRequest) error
	// SendSyncJob sends a job sync request
	SendSyncJob(ctx context.Context, req *SyncJobRequest) error
}

BuilderTransport is for calls originating from the builder

type CompleteJobRequest

type CompleteJobRequest struct {
	BuilderID string
	Job       *Job
	Success   bool
}

type GRPCTransport

GRPCTransport implements the Transport interface using gRPC

func NewGRPCTransportFromAddress

func NewGRPCTransportFromAddress(
	address string,
	cfg grpcclient.Config,
	reg prometheus.Registerer,
) (*GRPCTransport, error)

NewGRPCTransportFromAddress creates a new gRPC transport instance from an address and dial options

func (*GRPCTransport) SendCompleteJob

func (t *GRPCTransport) SendCompleteJob(ctx context.Context, req *CompleteJobRequest) error

SendCompleteJob implements Transport

func (*GRPCTransport) SendGetJobRequest

func (t *GRPCTransport) SendGetJobRequest(ctx context.Context, req *GetJobRequest) (*GetJobResponse, error)

SendGetJobRequest implements Transport

func (*GRPCTransport) SendSyncJob

func (t *GRPCTransport) SendSyncJob(ctx context.Context, req *SyncJobRequest) error

SendSyncJob implements Transport

type GetJobRequest

type GetJobRequest struct {
	BuilderID string
}

Request/Response message types

type GetJobResponse

type GetJobResponse struct {
	Job *Job
	OK  bool
}

type Job

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

Job represents a block building task.

func NewJob

func NewJob(partition int32, offsets Offsets) *Job

NewJob creates a new job with the given partition and offsets

func (*Job) ID

func (j *Job) ID() string

func (*Job) Offsets

func (j *Job) Offsets() Offsets

func (*Job) Partition

func (j *Job) Partition() int32

type JobStatus

type JobStatus int

JobStatus represents the current state of a job

const (
	JobStatusUnknown JobStatus = iota // zero value, largely unused
	JobStatusPending
	JobStatusInProgress
	JobStatusComplete
	JobStatusFailed  // Job failed and may be retried
	JobStatusExpired // Job failed too many times or is too old
)

func (JobStatus) IsFinished

func (s JobStatus) IsFinished() bool

func (JobStatus) String

func (s JobStatus) String() string

type MemoryTransport

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

MemoryTransport implements Transport interface for in-memory communication

func NewMemoryTransport

func NewMemoryTransport(scheduler SchedulerHandler) *MemoryTransport

NewMemoryTransport creates a new in-memory transport instance

func (*MemoryTransport) SendCompleteJob

func (t *MemoryTransport) SendCompleteJob(ctx context.Context, req *CompleteJobRequest) error

func (*MemoryTransport) SendGetJobRequest

func (t *MemoryTransport) SendGetJobRequest(ctx context.Context, _ *GetJobRequest) (*GetJobResponse, error)

func (*MemoryTransport) SendSyncJob

func (t *MemoryTransport) SendSyncJob(ctx context.Context, req *SyncJobRequest) error

type Offsets

type Offsets struct {
	Min int64
	Max int64
}

Offsets represents the range of offsets to process [Min,Max) exclusivity

type SchedulerHandler

type SchedulerHandler interface {
	// HandleGetJob processes a request for a new job
	HandleGetJob(ctx context.Context) (*Job, bool, error)
	// HandleCompleteJob processes a job completion notification
	HandleCompleteJob(ctx context.Context, job *Job, success bool) error
	// HandleSyncJob processes a job sync request
	HandleSyncJob(ctx context.Context, job *Job) error
}

SchedulerHandler defines the business logic for handling builder requests

type SyncJobRequest

type SyncJobRequest struct {
	BuilderID string
	Job       *Job
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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