rpc

package
v0.0.41 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 23 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

Index

Constants

View Source
const (
	CtxKeyTokenType = "rpc.token.type"
	CtxKeyWorkerID  = "rpc.token.worker_id"
	CtxKeyScopes    = "rpc.token.scopes"
)
View Source
const (
	ClearReasonActiveTasks     = "active_tasks"
	ClearReasonMultipleWorkers = "multiple_workers"
	ClearReasonNoContext       = "no_context"
)
View Source
const CtxScopesKey ctxKey = CtxKeyScopes

Mirrors CtxKeyScopes from auth middleware; see CtxWorkerIDKey comment above.

View Source
const CtxWorkerIDKey ctxKey = CtxKeyWorkerID

Uses the same string value as CtxKeyWorkerID (auth middleware on gin.Context) so the two stay in sync without a hard import dependency between packages. Exported so tests can construct contexts that simulate worker calls.

Variables

This section is empty.

Functions

func JWTAuthMiddleware

func JWTAuthMiddleware(secret string) gin.HandlerFunc

JWTAuthMiddleware validates the RPC JWT and writes claims to gin.Context. Reads the token from X-API-Key header or api_key query param. Returns 401 on missing, invalid, or expired token.

func RequireBeeOrWorker

func RequireBeeOrWorker() gin.HandlerFunc

RequireBeeOrWorker accepts tokens of either type.

Types

type ActiveTaskSummary

type ActiveTaskSummary struct {
	TaskID      string `json:"task_id"`
	Instruction string `json:"instruction"`
	Status      string `json:"status"`
}

type LinkedWorkerSummary

type LinkedWorkerSummary struct {
	WorkerID string `json:"worker_id"`
	Name     string `json:"name"`
}

type Server

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

Server dispatches tool calls.

func (*Server) CallTool

func (s *Server) CallTool(ctx context.Context, name string, args json.RawMessage) (any, error)

CallTool is exported for testing only.

func (*Server) HandleCall

func (s *Server) HandleCall(c *gin.Context)

Tool errors are returned as 200 {"error": "..."} to match the RPC-over-HTTP convention.

Jump to

Keyboard shortcuts

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