handler

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

JobHandler implements the Console BFF JobService:

  • Routes all job lifecycle calls (Enqueue / Get / List / Cancel) through the Planner. The Planner owns JobID -> MDS batch.ID translation; the handler never holds an MDS batch.ID.
  • Persists Console-owned fields (id, display name, created_by, future: organization, tags ...) in the local store.
  • Aggregates Planner Jobs into the wire-level *pb.Job returned to the UI.

The AIBrix-only extension `aibrix.model_template` is forwarded to MDS by the planner's BatchClient via the OpenAI SDK's `extra_body` channel.

When the planner / metadata service is unreachable the handler propagates the error (codes.Unavailable). The frontend renders its mock fallback in that case.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyHandler

type APIKeyHandler struct {
	pb.UnimplementedAPIKeyServiceServer
	// contains filtered or unexported fields
}

func NewAPIKeyHandler

func NewAPIKeyHandler(s store.Store) *APIKeyHandler

func (*APIKeyHandler) CreateAPIKey

func (*APIKeyHandler) DeleteAPIKey

func (h *APIKeyHandler) DeleteAPIKey(ctx context.Context, req *pb.DeleteAPIKeyRequest) (*emptypb.Empty, error)

func (*APIKeyHandler) ListAPIKeys

type DeploymentHandler

type DeploymentHandler struct {
	pb.UnimplementedDeploymentServiceServer
	// contains filtered or unexported fields
}

func NewDeploymentHandler

func NewDeploymentHandler(s store.Store) *DeploymentHandler

func (*DeploymentHandler) CreateDeployment

func (h *DeploymentHandler) CreateDeployment(ctx context.Context, req *pb.CreateDeploymentRequest) (*pb.Deployment, error)

func (*DeploymentHandler) DeleteDeployment

func (h *DeploymentHandler) DeleteDeployment(ctx context.Context, req *pb.DeleteDeploymentRequest) (*emptypb.Empty, error)

func (*DeploymentHandler) GetDeployment

func (h *DeploymentHandler) GetDeployment(ctx context.Context, req *pb.GetDeploymentRequest) (*pb.Deployment, error)

func (*DeploymentHandler) ListDeployments

type FileHandler

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

FileHandler proxies file operations to the AIBrix metadata service.

func NewFileHandler

func NewFileHandler(metadataServiceURL string, injector error_injection.Injector, stores ...store.Store) *FileHandler

NewFileHandler creates a new file proxy handler.

func (*FileHandler) RegisterRoutes

func (h *FileHandler) RegisterRoutes(mux *runtime.ServeMux)

RegisterRoutes registers file proxy routes on the given ServeMux.

type InjectionHandler

type InjectionHandler struct {
	pb.UnimplementedInjectionServiceServer
	// contains filtered or unexported fields
}

InjectionHandler implements console.v1.InjectionService.

func NewInjectionHandler

func NewInjectionHandler(injector error_injection.Injector, planner plannerapi.Planner) *InjectionHandler

NewInjectionHandler creates a new InjectionHandler.

func (*InjectionHandler) ClearInjectionConfig

func (h *InjectionHandler) ClearInjectionConfig(ctx context.Context, req *pb.ClearInjectionConfigRequest) (*emptypb.Empty, error)

ClearInjectionConfig clears the global injection configuration (disables injection).

func (*InjectionHandler) GetInjectionConfig

GetInjectionConfig returns the current global injection configuration.

func (*InjectionHandler) GetInjectionTrace

GetInjectionTrace retrieves the execution trace for a specific job.

func (*InjectionHandler) ListInjectionPoints

ListInjectionPoints returns all registered injection points.

func (*InjectionHandler) SetInjectionConfig

SetInjectionConfig updates the global injection configuration.

type JobHandler

type JobHandler struct {
	pb.UnimplementedJobServiceServer
	// contains filtered or unexported fields
}

JobHandler implements console.v1.JobService.

func NewJobHandler

func NewJobHandler(s store.Store, planner plannerapi.Planner, defaultModelDeploymentTemplate string, devMode bool, injector error_injection.Injector) *JobHandler

NewJobHandler creates a JobHandler.

func (*JobHandler) CancelJob

func (h *JobHandler) CancelJob(ctx context.Context, req *pb.CancelJobRequest) (*pb.Job, error)

CancelJob routes through Planner.Cancel; the planner resolves JobID to MDS batch.ID and forwards to /v1/batches/{id}/cancel.

func (*JobHandler) CreateJob

func (h *JobHandler) CreateJob(ctx context.Context, req *pb.CreateJobRequest) (*pb.Job, error)

CreateJob calls POST /v1/batches with console-owned fields (display name, created_by, template binding) packed into batch.metadata under the aibrix.console.* namespace. The store-overlay path is intentionally parked while we treat MDS batch.metadata as the single source of truth for the e2e demo loop; the store layer (UpsertJob/GetJob/ListJobs) stays in place for the future reconcile / annotations design (see #8 discussion).

Per-batch sampling params (max_tokens / temperature / top_p / n) are baked into the JSONL by the console wizard before upload, so they don't appear on this request. The OpenAI SDK path can still POST them to MDS directly.

func (*JobHandler) GetJob

func (h *JobHandler) GetJob(ctx context.Context, req *pb.GetJobRequest) (*pb.Job, error)

GetJob proxies to GET /v1/batches/{id}. Planner owns JobID -> MDS batch.ID resolution and reads MDS whenever a batch exists, including terminal batches whose usage/output/extra_body fields are not stored locally.

func (*JobHandler) ListJobs

func (h *JobHandler) ListJobs(ctx context.Context, req *pb.ListJobsRequest) (*pb.ListJobsResponse, error)

ListJobs proxies to GET /v1/batches. Console-owned fields ride on batch.metadata; the store overlay path is parked (see CreateJob).

type ModelDeploymentTemplateHandler

type ModelDeploymentTemplateHandler struct {
	pb.UnimplementedModelDeploymentTemplateServiceServer
	// contains filtered or unexported fields
}

func NewModelDeploymentTemplateHandler

func NewModelDeploymentTemplateHandler(s store.Store) *ModelDeploymentTemplateHandler

func (*ModelDeploymentTemplateHandler) CreateModelDeploymentTemplate

func (*ModelDeploymentTemplateHandler) DeleteModelDeploymentTemplate

func (*ModelDeploymentTemplateHandler) GetModelDeploymentTemplate

func (*ModelDeploymentTemplateHandler) ListModelDeploymentTemplates

func (*ModelDeploymentTemplateHandler) ResolveModelDeploymentTemplate

func (*ModelDeploymentTemplateHandler) UpdateModelDeploymentTemplate

type ModelHandler

type ModelHandler struct {
	pb.UnimplementedModelServiceServer
	// contains filtered or unexported fields
}

func NewModelHandler

func NewModelHandler(s store.Store) *ModelHandler

func (*ModelHandler) CreateModel

func (h *ModelHandler) CreateModel(ctx context.Context, req *pb.CreateModelRequest) (*pb.Model, error)

func (*ModelHandler) GetModel

func (h *ModelHandler) GetModel(ctx context.Context, req *pb.GetModelRequest) (*pb.Model, error)

func (*ModelHandler) ListModels

type PlaygroundHandler

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

PlaygroundHandler proxies chat completion requests to the AIBrix gateway as SSE.

func NewPlaygroundHandler

func NewPlaygroundHandler(gatewayEndpoint string) *PlaygroundHandler

NewPlaygroundHandler creates a new playground SSE proxy handler.

func (*PlaygroundHandler) HandleChatCompletion

func (h *PlaygroundHandler) HandleChatCompletion(w http.ResponseWriter, r *http.Request, _ map[string]string)

HandleChatCompletion proxies the request to AIBrix gateway and streams SSE back.

type QuotaHandler

type QuotaHandler struct {
	pb.UnimplementedQuotaServiceServer
	// contains filtered or unexported fields
}

func NewQuotaHandler

func NewQuotaHandler(s store.Store) *QuotaHandler

func (*QuotaHandler) ListQuotas

type SecretHandler

type SecretHandler struct {
	pb.UnimplementedSecretServiceServer
	// contains filtered or unexported fields
}

func NewSecretHandler

func NewSecretHandler(s store.Store) *SecretHandler

func (*SecretHandler) CreateSecret

func (h *SecretHandler) CreateSecret(ctx context.Context, req *pb.CreateSecretRequest) (*pb.Secret, error)

func (*SecretHandler) DeleteSecret

func (h *SecretHandler) DeleteSecret(ctx context.Context, req *pb.DeleteSecretRequest) (*emptypb.Empty, error)

func (*SecretHandler) ListSecrets

Jump to

Keyboard shortcuts

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