bridge

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bridge implements the gRPC server that runners connect to. It bridges the transport layer (JobQueue + EventBroker) with the gRPC RunnerService protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamAuthInterceptor

func StreamAuthInterceptor(rt *auth.RunnerTokens) grpc.StreamServerInterceptor

StreamAuthInterceptor enforces runner auth on streaming RPCs (StreamEvents, WatchCancels).

func UnaryAuthInterceptor

func UnaryAuthInterceptor(rt *auth.RunnerTokens) grpc.UnaryServerInterceptor

UnaryAuthInterceptor enforces runner auth on unary RPCs (GetJob, ReportStatus).

Types

type Server

type Server struct {
	pb.UnimplementedRunnerServiceServer
	// contains filtered or unexported fields
}

Server implements the RunnerService gRPC server.

func NewServer

func NewServer(queue transport.JobQueue, broker transport.EventBroker, cancelBus transport.CancelBroker, onStatus func(runID, status, errorMsg string)) *Server

NewServer creates a bridge server backed by the given queue, broker, and cancel bus.

func (*Server) GetJob

func (s *Server) GetJob(ctx context.Context, req *pb.GetJobRequest) (*pb.GetJobResponse, error)

GetJob implements the long-poll pattern: blocks until a job is available.

func (*Server) Heartbeat

func (s *Server) Heartbeat(ctx context.Context, req *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error)

Heartbeat is called periodically by the runner while a run is actively executing -- extends the job's in-flight lease so the stale-job reaper's "time since last touch" check reflects real liveness for the whole run, not just the window up to the first StreamEvents message. A runner that stops heartbeating (crashed, or simply doesn't implement this RPC) falls stale after the reaper's max-age and gets reclaimed by the existing mechanism -- this adds no new reclaim path, just keeps resetting the clock during real work. Always returns ok:true even if the run_id is no longer in-flight (already completed, or reclaimed away) -- a late heartbeat racing completion is expected, not an error condition.

Fenced by generation: if a NEWER generation has already been dispatched (this runner was reclaimed while genuinely still executing, then its blip turned out to be transient), Renew returns current=false and this response carries Superseded=true -- this is the runner's OWN, actionable signal that it's lost its lease and should stop, delivered at the next ~2s heartbeat tick rather than only once it eventually finishes and calls ReportStatus.

func (*Server) ReportStatus

func (s *Server) ReportStatus(ctx context.Context, req *pb.ReportStatusRequest) (*pb.ReportStatusResponse, error)

ReportStatus receives the final status from the runner. Fenced by generation: a runner that was reclaimed and replaced while genuinely still executing (a transient blip made it miss the reaper's max-age window) might finish its own stale work anyway and call this late, after a second runner already took over and may have its own status pending or already reported. Accepting that stale report here -- applying its status, or Acking a slot that no longer belongs to this attempt -- would let it clobber or race the real outcome. See RunAssignment.Generation's own doc comment for the full mechanism.

func (*Server) SetRunLifecycle

func (s *Server) SetRunLifecycle(attempt func(context.Context, string, int64) (bool, error), complete func(context.Context, *state.RunCompletion) (bool, error))

SetRunLifecycle attaches durable attempt fencing and completion persistence.

func (*Server) StreamEvents

func (s *Server) StreamEvents(stream pb.RunnerService_StreamEventsServer) error

StreamEvents receives a stream of events from the runner and publishes them to the event broker for SSE fan-out.

func (*Server) WatchCancels

func (s *Server) WatchCancels(req *pb.WatchCancelsRequest, stream pb.RunnerService_WatchCancelsServer) error

WatchCancels streams cancel signals to the runner. The runner calls this once at startup. The bridge sends a CancelSignal whenever a run dispatched to this runner_kind is cancelled.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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