router

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0, MIT Imports: 49 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAsyncqClient

func NewAsyncqClient() (*asynq.Client, error)

func NewAsynqInspector

func NewAsynqInspector(redisClient *redis.Client) *asynq.Inspector

NewAsynqInspector constructs an *asynq.Inspector pointed at the same Redis used by the asynq client. Only registered in asynq mode.

func NewAsynqTaskInspector

func NewAsynqTaskInspector(inspector *asynq.Inspector, redisClient *redis.Client) interfaces.TaskInspector

NewAsynqTaskInspector returns a TaskInspector wrapping the given *asynq.Inspector. nil-safe: a nil inspector degrades to a no-op so the cancel path remains usable when the inspector failed to init.

func NewCoreAsynqServer

func NewCoreAsynqServer(svc interfaces.SystemSettingService) *asynq.Server

NewCoreAsynqServer runs document and manual parsing with guaranteed capacity.

func NewEnrichmentAsynqServer

func NewEnrichmentAsynqServer(svc interfaces.SystemSettingService) *asynq.Server

NewEnrichmentAsynqServer runs high-fanout summary, multimodal, graph, and question generation without consuming core parsing capacity.

func NewMaintenanceAsynqServer

func NewMaintenanceAsynqServer(svc interfaces.SystemSettingService) *asynq.Server

NewMaintenanceAsynqServer runs connector sync, cleanup, deletion, and batch dispatch work. QueueMaintenance keeps the legacy Redis name "low", so old tasks are drained safely during rolling upgrades.

func NewNoopTaskInspector

func NewNoopTaskInspector() interfaces.TaskInspector

NewNoopTaskInspector returns a no-op TaskInspector for Lite mode.

func NewPostProcessAsynqServer

func NewPostProcessAsynqServer(svc interfaces.SystemSettingService) *asynq.Server

NewPostProcessAsynqServer reserves capacity for the lightweight but latency-sensitive fan-out stage. It cannot be trapped behind a burst of long-running document parses in QueueDefault.

func NewRouter

func NewRouter(params RouterParams) *gin.Engine

NewRouter 创建新的路由

func NewSharedAsynqServer

func NewSharedAsynqServer(svc interfaces.SystemSettingService) *asynq.Server

NewSharedAsynqServer is the elastic tier. Asynq dequeue is atomic, so it is safe for this server and the dedicated servers to subscribe to the same queues: every task is still executed by exactly one worker.

func NewWikiAsynqServer

func NewWikiAsynqServer(svc interfaces.SystemSettingService) *asynq.Server

NewWikiAsynqServer builds the dedicated wiki pool: QueueWiki only. It runs the shared handler mux but only ever pulls wiki tasks, so its concurrency budget (WEKNORA_WIKI_ASYNQ_CONCURRENCY, default 8) is spent exclusively on wiki generation. This is the hard capacity isolation that prevents the parse pipeline from starving wiki (and vice-versa) during concurrent uploads.

func RegisterAuthRoutes

func RegisterAuthRoutes(r *gin.RouterGroup, handler *handler.AuthHandler, g *rbacGuards)

RegisterAuthRoutes registers authentication routes

func RegisterAutomationRoutes added in v0.9.0

func RegisterAutomationRoutes(r *gin.RouterGroup, h *handler.AutomationHandler, g *rbacGuards)

RegisterAutomationRoutes registers the caller's automations and in-app notifications. An automation runs as the person who made it, and the service scopes every route to the caller's own records, so tenant members (Viewer+) may use them. They are not declared for API keys (default-deny): an automation needs a signed-in owner.

func RegisterChatRoutes

func RegisterChatRoutes(r *gin.RouterGroup, handler *session.Handler, g *rbacGuards)

RegisterChatRoutes 注册路由。Chat endpoints are tenant-member usage surfaces; Viewer+ is sufficient because per-session/per-agent authorisation is enforced inside the handlers.

func RegisterChunkRoutes

func RegisterChunkRoutes(r *gin.RouterGroup, handler *handler.ChunkHandler, g *rbacGuards)

RegisterChunkRoutes 注册分块相关的路由

Mutating routes addressed via :knowledge_id inherit per-KB ownership from the owning knowledge entry's KB (PR 5, #1303); the chain hop is shared with RegisterKnowledgeRoutes via OwnedChunkKBOrAdmin so the same "creator-of-the-KB OR Admin+" rule applies to chunk edits.

func RegisterChunkerDebugRoutes

func RegisterChunkerDebugRoutes(r *gin.RouterGroup, g *rbacGuards)

RegisterChunkerDebugRoutes wires the read-only chunker preview endpoint used by the KB editor's debug panel. Stateless — uses no service deps.

Viewer+ floor: the endpoint surfaces inside the tenant UI, so any authenticated tenant member can call it; revoked accounts whose JWT has not yet expired are kept out by the role check, matching the rest of the RBAC matrix in this file.

func RegisterCustomAgentRoutes

func RegisterCustomAgentRoutes(r *gin.RouterGroup, agentHandler *handler.CustomAgentHandler, g *rbacGuards)

RegisterCustomAgentRoutes registers custom agent routes.

Mutating routes use OwnedAgentOrAdmin: the original creator can edit their agent, otherwise Admin+ is required. Built-in agents (IsBuiltin=true) have an empty creator and are always Admin+. Reads are Viewer+, copy is Contributor+ (the copy is owned by the caller).

func RegisterDataSourceRoutes

func RegisterDataSourceRoutes(
	r *gin.RouterGroup,
	handler *handler.DataSourceHandler,
	credHandler *handler.DataSourceCredentialsHandler,
	g *rbacGuards,
)

RegisterDataSourceRoutes 注册数据源相关的路由

Data sources hold external service credentials (Feishu/Notion/Yuque) and trigger sync jobs that mutate KB content tenant-wide. Reads are Viewer+; everything else (CRUD, validation, sync control, credential subresource) is Admin+.

func RegisterEmbedChannelRoutes

func RegisterEmbedChannelRoutes(r *gin.RouterGroup, embedHandler *handler.EmbedChannelHandler, g *rbacGuards)

RegisterEmbedChannelRoutes registers authenticated embed channel management routes.

func RegisterEmbedPublicRoutes

func RegisterEmbedPublicRoutes(
	r *gin.Engine,
	embedHandler *handler.EmbedChannelHandler,
	embedService interfaces.EmbedChannelService,
	tenantService interfaces.TenantService,
	redisClient *redis.Client,
	fileService interfaces.FileService,
	storageResolver interfaces.StorageBackendResolver,
	resourceCatalogs ...interfaces.ResourceCatalog,
)

RegisterEmbedPublicRoutes registers anonymous embed endpoints secured by publish tokens.

func RegisterEvaluationRoutes

func RegisterEvaluationRoutes(r *gin.RouterGroup, handler *handler.EvaluationHandler, g *rbacGuards)

RegisterEvaluationRoutes registers evaluation endpoints. Running an evaluation drives LLM calls (cost) and reads from KBs across the tenant; gate to Admin+ until product asks for a finer-grained matrix.

func RegisterFAQRoutes

func RegisterFAQRoutes(r *gin.RouterGroup, handler *handler.FAQHandler, g *rbacGuards)

RegisterFAQRoutes 注册 FAQ 相关路由

FAQ entries are KB content: reads are Viewer+, all mutations (create / update / upsert / delete / batch field+tag updates, import display flag) are Contributor+. Search is read-only.

func RegisterGraphSearchRoutes added in v0.9.0

func RegisterGraphSearchRoutes(r *gin.RouterGroup, h *handler.GraphSearchHandler, g *rbacGuards)

RegisterGraphSearchRoutes is a read-only KB content route, even though the query is POSTed. Role, API-key capability and exact KB grant are independent.

func RegisterIMChannelRoutes

func RegisterIMChannelRoutes(r *gin.RouterGroup, imHandler *handler.IMHandler, g *rbacGuards)

RegisterIMChannelRoutes registers IM channel CRUD routes (requires authentication).

IM channels carry external bot credentials (WeChat/Feishu/Slack/...); listing is Viewer+ but any mutation, toggle, or QR-code login flow (which can hijack a personal WeChat session) is Admin+.

func RegisterIMRoutes

func RegisterIMRoutes(r *gin.Engine, imHandler *handler.IMHandler)

RegisterIMRoutes registers IM callback routes. These are registered BEFORE auth middleware since IM platforms use their own signature verification.

func RegisterImageAttrRoutes

func RegisterImageAttrRoutes(r *gin.RouterGroup, handler *handler.KnowledgeBaseHandler, g *rbacGuards)

RegisterImageAttrRoutes wires the global, read-only image-attribute registry that drives the KB editor's attribute panel.

The registry is a single source of truth, so adding an attribute is a backend-only change (one registry row) and the UI follows automatically. It carries no KB id and needs only the Viewer role, so — like the other read-only KB-editor helpers GET /chunker/preview and GET /system/parser-engines — it is mounted at the top level rather than under the /knowledge-bases collection.

func RegisterInitializationRoutes

func RegisterInitializationRoutes(r *gin.RouterGroup, handler *handler.InitializationHandler, g *rbacGuards)

func RegisterKnowledgeBaseActivityRoutes

func RegisterKnowledgeBaseActivityRoutes(r *gin.RouterGroup, auditHandler *handler.AuditLogHandler, g *rbacGuards)

RegisterKnowledgeBaseActivityRoutes exposes the read-only per-KB activity feed. It intentionally stays JWT-only: audit history is a sensitive owner surface and no existing workspace API-key capability grants audit access.

func RegisterKnowledgeBaseRoutes

func RegisterKnowledgeBaseRoutes(r *gin.RouterGroup, handler *handler.KnowledgeBaseHandler, g *rbacGuards)

RegisterKnowledgeBaseRoutes 注册知识库相关的路由

func RegisterKnowledgeRoutes

func RegisterKnowledgeRoutes(r *gin.RouterGroup, handler *handler.KnowledgeHandler, g *rbacGuards)

RegisterKnowledgeRoutes 注册知识相关的路由

Per-KB ownership applies on the per-:id mutating routes (PR 5, #1303): the URL :id is a knowledge id, OwnedKnowledgeKBOrAdmin walks it back to KB.CreatorID so a Contributor who owns the KB can edit/delete any of its documents while a non-owner Contributor gets 403. KB-scoped upload routes (`/knowledge-bases/:id/knowledge/...`) reuse OwnedKBOrAdmin because the URL :id is the KB id directly. Body-scoped batch operations have a Contributor route gate and resolve their KB ownership plus Editor operation grant inside the handler.

func RegisterKnowledgeTagRoutes

func RegisterKnowledgeTagRoutes(r *gin.RouterGroup, tagHandler *handler.TagHandler, g *rbacGuards)

RegisterKnowledgeTagRoutes 注册知识库标签相关路由。

Tags are KB metadata: Viewer reads, Contributor writes. Per-KB ownership granularity for tags is out of scope for PR 2; this is purely role-based.

func RegisterMCPEndpointRoutes

func RegisterMCPEndpointRoutes(r *gin.RouterGroup, h *handler.MCPEndpointHandler, g *rbacGuards)

RegisterMCPEndpointRoutes registers the management API for workspace MCP endpoints. Endpoints are tenant-wide integration surfaces like embed channels: reads for every member, mutations for admins, and API keys need the manage_channels capability.

func RegisterMCPServerRoutes

func RegisterMCPServerRoutes(
	r *gin.Engine,
	srv *mcpserver.Server,
	endpointService interfaces.MCPEndpointService,
	tenantService interfaces.TenantService,
)

RegisterMCPServerRoutes mounts the public MCP server surface at /mcp/:endpoint_id. It carries its own bearer-token auth and is registered before the global Auth middleware, like the embed public routes.

func RegisterMCPServiceRoutes

func RegisterMCPServiceRoutes(
	r *gin.RouterGroup,
	handler *handler.MCPServiceHandler,
	credHandler *handler.MCPCredentialsHandler,
	oauthHandler *handler.MCPOAuthHandler,
	g *rbacGuards,
)

RegisterMCPServiceRoutes registers MCP service routes.

MCP services are tenant-level integrations (external tool servers); we gate reads to Viewer+ and any mutation/test to Admin+. Tool-approval resolution is also Admin+ since approving a pending tool call grants the agent permission to execute side-effecting external commands. Credential subresource writes are Admin+ as well since secrets are tenant-scoped.

func RegisterMemoryRoutes

func RegisterMemoryRoutes(r *gin.RouterGroup, memoryHandler *handler.MemoryHandler, g *rbacGuards)

RegisterMemoryRoutes registers the personal long-term memory endpoints.

There is no admin surface here and no subject parameter anywhere in the paths: the memory space is derived from the caller's principal, so these routes can only ever read or write the caller's own memories. That is why Viewer is the only role gate they need. An API key must be full-access, since a memory space belongs to a person and a scoped integration key has no business inheriting one.

func RegisterMessageRoutes

func RegisterMessageRoutes(r *gin.RouterGroup, handler *handler.MessageHandler, g *rbacGuards)

RegisterMessageRoutes 注册消息相关的路由。

Per-session ownership is already enforced inside each handler (the user must own the session). We add Viewer+ here so non-members (e.g. revoked accounts retained in the tenant for audit) cannot reach the endpoints at all once RBAC is on.

func RegisterModelRoutes

func RegisterModelRoutes(
	r *gin.RouterGroup,
	handler *handler.ModelHandler,
	credHandler *handler.ModelCredentialsHandler,
	g *rbacGuards,
)

Models are tenant-wide infrastructure (LLM credentials, embeddings, rerankers); Viewer+ for reads, Admin+ for any mutation. Credential subresource writes are also Admin+ since secrets are tenant-scoped.

func RegisterMyEnvVarRoutes

func RegisterMyEnvVarRoutes(r *gin.RouterGroup, h *handler.MeEnvVarHandler)

RegisterMyEnvVarRoutes wires the caller's own environment variables under /me/env-vars. The v1 group already applies middleware.Auth, and no role gate is added on purpose: these are the caller's own values, and the service derives whose they are from the context rather than the request.

This deliberately does not reuse /sandbox-configs/:id/skills*, which is Admin+ even for reads (see routes_infra.go): an upload there drives a root shell whose output is baked into the image, and the listing names what that image carries. This endpoint returns declarations and set/unset status only.

h may be nil in environments built without the dependency wired; a no-op registration is preferable to a startup crash, as with the invitation inbox.

func RegisterMyInvitationRoutes

func RegisterMyInvitationRoutes(r *gin.RouterGroup, invitationHandler *handler.TenantInvitationHandler)

RegisterMyInvitationRoutes wires the per-user invitation inbox under /me/invitations. The v1 group already applies middleware.Auth so we don't need a role gate here — the service enforces "only the invitee can accept/decline". The list endpoint mounts under /me to make the "show me MY invitations" semantics obvious in URLs and logs (vs the tenant-scoped /tenants/:id/invitations which lists ALL invitations for the tenant). pending-count is a separate, ultra-light endpoint the avatar-row badge polls; splitting it off so polling doesn't transfer the full list every cycle.

invitationHandler may be nil in environments built without the invitation dependency wired; that's a no-op registration which is preferable to a startup crash.

func RegisterOrganizationRoutes

func RegisterOrganizationRoutes(r *gin.RouterGroup, orgHandler *handler.OrganizationHandler, g *rbacGuards)

RegisterOrganizationRoutes registers organization and sharing routes

func RegisterSandboxConfigRoutes

func RegisterSandboxConfigRoutes(
	r *gin.RouterGroup,
	h *handler.SandboxConfigHandler,
	skills *handler.SandboxSkillHandler,
	g *rbacGuards,
)

Sandbox configs are workspace infrastructure that hold provider credentials. Scoped API keys cannot safely receive partial authority over them yet because mutation can strand remote sandboxes.

func RegisterSandboxDesktopRoutes

func RegisterSandboxDesktopRoutes(r *gin.Engine, sessionHandler *session.Handler)

RegisterSandboxDesktopRoutes registers the desktop relay WebSocket.

Registered BEFORE the global auth middleware for the same reason as the terminal: a browser WebSocket handshake cannot carry Authorization, so a one-shot session-bound ticket travels in the query string. Unlike the terminal's JWT the desktop ticket is an opaque random string consumed with GETDEL, so a leaked URL is worth one handshake at most.

The wildcard is :id to match /sessions/:id in the same radix tree.

func RegisterSandboxTerminalRoutes

func RegisterSandboxTerminalRoutes(r *gin.Engine, sessionHandler *session.Handler)

RegisterSandboxTerminalRoutes registers the interactive-terminal WebSocket.

Like the IM callback routes this is registered BEFORE the global auth middleware: a browser WebSocket handshake cannot carry the Authorization / X-API-Key headers, so a short-lived session-bound ticket travels in the ticket query parameter. The handler authenticates itself via service.ParseSandboxTerminalTicket + CheckSandboxTerminalAuth + middleware.AttachAuthenticatedUser (not the 24h access JWT). The ticket is bound to the minting access-token id; the open PTY rechecks that token, user, membership, and session ownership about once a minute.

The wildcard is :id because this GET joins the same radix tree as /sessions/:id (gin requires identical wildcard names per tree).

func RegisterSessionRoutes

func RegisterSessionRoutes(
	r *gin.RouterGroup,
	handler *session.Handler,
	suggestionHandler *handler.MessageSuggestionHandler,
	g *rbacGuards,
)

RegisterSessionRoutes 注册路由。

Sessions are per-user resources; the handler enforces user ownership. We gate at Viewer+ to keep non-members out once RBAC is on, matching the message routes above. A future refactor can introduce per-session ownership in the middleware layer the same way KB/agent routes do today.

func RegisterSkillRoutes

func RegisterSkillRoutes(r *gin.RouterGroup, skillHandler *handler.SkillHandler, g *rbacGuards)

RegisterSkillRoutes registers skill routes.

PR 2 currently only exposes a read-only `ListSkills`; gated to Viewer+. Future skill upload / enable endpoints must use Admin+ since skills run sandboxed code on tenant resources.

func RegisterStorageBackendRoutes

func RegisterStorageBackendRoutes(r *gin.RouterGroup, h *handler.StorageBackendHandler, g *rbacGuards)

RegisterStorageBackendRoutes manages concrete object/file storage instances.

func RegisterSyncHandlers

func RegisterSyncHandlers(params SyncTaskParams)

RegisterSyncHandlers registers all task handlers on the SyncTaskExecutor. Used in Lite mode instead of RunAsynqServer.

func RegisterSystemAdminRoutes

func RegisterSystemAdminRoutes(
	r *gin.RouterGroup,
	handler *handler.SystemHandler,
	auditLogHandler *handler.AuditLogHandler,
	g *rbacGuards,
)

RegisterSystemAdminRoutes registers system administration routes.

All endpoints under this group are gated to SystemAdmin users (i.e. User.IsSystemAdmin == true). These are platform-wide operations independent of per-tenant Owner/Admin/Contributor/Viewer roles — they let org-level superusers grant/revoke system-admin status and, in later milestones, will host global settings, built-in models, and cross-tenant observability.

Mounted under /api/v1/system/admin/* so the URL scheme stays aligned with the existing /api/v1/system/info family. Front-end clients live in frontend/src/api/system/index.ts.

auditLogHandler may be nil in environments wired without the audit dependency; the /audit-log subroute is then omitted. This mirrors the optional wiring in RegisterTenantRoutes.

func RegisterSystemRoutes

func RegisterSystemRoutes(
	r *gin.RouterGroup,
	handler *handler.SystemHandler,
	g *rbacGuards,
)

RegisterSystemRoutes registers system information routes

Reads (GetSystemInfo / ListParserEngines / GetStorageEngineStatus) are gated to Viewer+ — any tenant member can see "is the parser reachable". The /*-check / /reconnect endpoints actively probe remote services with tenant credentials and could trigger network fanout, so they're Admin+.

func RegisterTenantRoutes

func RegisterTenantRoutes(
	r *gin.RouterGroup,
	handler *handler.TenantHandler,
	memberHandler *handler.TenantMemberHandler,
	invitationHandler *handler.TenantInvitationHandler,
	auditLogHandler *handler.AuditLogHandler,
	g *rbacGuards,
)

RegisterTenantRoutes 注册空间相关的路由

Tenant-internal RBAC for /tenants/:id:

  • GET /:id Viewer+ (read tenant settings)
  • PUT /:id Owner+ (mutate tenant config)
  • DELETE /:id Owner+ (also normally a CanAccessAllTenants op)
  • GET/POST/PUT/DELETE /:id/api-keys Owner+ (scoped API key management)
  • GET /:id/members Viewer+ (any member can see who else is in)
  • POST /:id/members Owner+ (only Owner can add new members)
  • PUT /:id/members/:user_id Owner+ (only Owner can change roles)
  • DELETE /:id/members/:user_id Owner+ (only Owner can remove members)
  • POST /:id/leave Viewer+ (any member can quit on their own)

All /tenants/:id endpoints share g.PathTenantMatch() at the group level: middleware/access.go enforces "URL :id == active tenant" (with the cross-tenant superuser carve-out) so an Owner-of-A cannot drive operations against tenant B by changing the URL. This used to be authorizeTenantAccess in tenant.go and resolveTenantIDFromPath in tenant_member.go; collapsing it into one route guard means the declaration itself documents the rule.

Cross-tenant superuser endpoints (/tenants/all, /tenants/search) use g.CrossTenant(): RequireCrossTenantAccess in access.go combines the CanAccessAllTenants user attribute with the cluster-wide EnableCrossTenantAccess flag, replacing the 12-line if-block that previously opened ListAllTenants and SearchTenants.

JWT behavior for POST /tenants and GET /tenants remains unchanged. Platform API keys may create tenants through system_tenants_manage; workspace keys remain default-denied on tenant-catalog operations.

func RegisterUserFavoriteRoutes

func RegisterUserFavoriteRoutes(r *gin.RouterGroup, h *handler.UserResourceFavoriteHandler, g *rbacGuards)

RegisterUserFavoriteRoutes wires the per-user starred-resource endpoints.

Authorization: the handler always derives (user_id, tenant_id) from the auth context — there is no admin-style "see another user's favorites" path — so a Viewer floor is the right gate. The endpoints intentionally don't follow the OwnedXOrAdmin pattern: favorites aren't owned by the resource's creator, they're owned by the user *doing* the starring.

func RegisterVectorStoreRoutes

func RegisterVectorStoreRoutes(r *gin.RouterGroup, h *handler.VectorStoreHandler, g *rbacGuards)

RegisterVectorStoreRoutes registers CRUD routes for vector store configurations.

Vector stores are tenant-level infrastructure; reads are Viewer+, all writes (and connection tests, which probe external systems with stored credentials) are Admin+.

func RegisterWeKnoraCloudRoutes

func RegisterWeKnoraCloudRoutes(r *gin.RouterGroup, handler *handler.WeKnoraCloudHandler, g *rbacGuards)

RegisterWeKnoraCloudRoutes 注册 WeKnoraCloud 初始化路由 RegisterWeKnoraCloudRoutes registers the WeKnoraCloud credential management endpoints. SaveCredentials persists external SaaS keys for the tenant (Admin+), Status is a low-risk readiness probe (Viewer+).

func RegisterWebSearchProviderRoutes

func RegisterWebSearchProviderRoutes(
	r *gin.RouterGroup,
	h *handler.WebSearchProviderHandler,
	credHandler *handler.WebSearchProviderCredentialsHandler,
	g *rbacGuards,
)

RegisterWebSearchProviderRoutes registers CRUD routes for web search provider configurations.

Provider rows hold external service credentials (Bing, Tavily, Google, etc.); reads are Viewer+, all mutations / connection tests (which probe external systems with stored credentials) and the per-field credential subresource are Admin+.

func RegisterWebSearchRoutes

func RegisterWebSearchRoutes(r *gin.RouterGroup, webSearchHandler *handler.WebSearchHandler, g *rbacGuards)

RegisterWebSearchRoutes registers web search routes

func RegisterWikiPageRoutes

func RegisterWikiPageRoutes(r *gin.RouterGroup, wikiHandler *handler.WikiPageHandler, g *rbacGuards)

RegisterWikiPageRoutes registers wiki page related routes.

Wiki pages are KB content (wiki mode): reads are Viewer+ and gated by KBAccessRead (own / org-shared / via shared agent), matching FAQ / chunk / tag read routes. Content mutations (create/update/delete) and maintenance actions (rebuild-links, auto-fix, change issue status) honour per-KB ownership via OwnedWikiKBOrAdmin (PR 5, #1303): the URL :kb_id resolves directly to the owning KB so a Contributor who owns the KB can manage its wiki, while a non-owner Contributor gets 403.

func RunAsynqServer

func RunAsynqServer(params AsynqTaskParams) *asynq.ServeMux

Types

type AsynqTaskParams

type AsynqTaskParams struct {
	dig.In

	// Dedicated servers provide minimum capacity for parse, post-process,
	// enrichment, maintenance, and Wiki work. SharedServer is the elastic tier:
	// it also subscribes to core/enrichment queues so either stage can borrow
	// otherwise-idle capacity without consuming the other stage's guarantee.
	CoreServer           *asynq.Server `name:"coreAsynqServer"`
	PostProcessServer    *asynq.Server `name:"postProcessAsynqServer"`
	EnrichmentServer     *asynq.Server `name:"enrichmentAsynqServer"`
	MaintenanceServer    *asynq.Server `name:"maintenanceAsynqServer"`
	SharedServer         *asynq.Server `name:"sharedAsynqServer"`
	WikiServer           *asynq.Server `name:"wikiAsynqServer"`
	KnowledgeService     interfaces.KnowledgeService
	KnowledgeBaseService interfaces.KnowledgeBaseService
	TagService           interfaces.KnowledgeTagService
	DataSourceService    interfaces.DataSourceService
	ChunkExtractor       interfaces.TaskHandler `name:"chunkExtractor"`
	DataTableSummary     interfaces.TaskHandler `name:"dataTableSummary"`
	ImageMultimodal      interfaces.TaskHandler `name:"imageMultimodal"`
	KnowledgePostProcess interfaces.TaskHandler `name:"knowledgePostProcess"`
	KnowledgeAutoTag     interfaces.TaskHandler `name:"knowledgeAutoTag"`
	KnowledgeBaseProfile interfaces.TaskHandler `name:"knowledgeBaseProfile"`
	WikiIngest           interfaces.TaskHandler `name:"wikiIngest"`
	TemporaryDocument    interfaces.TemporaryDocumentService
	MemoryService        interfaces.MemoryService
	DeadLetterRepo       interfaces.TaskDeadLetterRepository
	SpanTracker          service.SpanTracker
}

type RouterParams

type RouterParams struct {
	dig.In

	Config                       *config.Config
	FileService                  interfaces.FileService
	UserService                  interfaces.UserService
	KBService                    interfaces.KnowledgeBaseService
	KnowledgeService             interfaces.KnowledgeService
	ChunkService                 interfaces.ChunkService
	SessionService               interfaces.SessionService
	MessageService               interfaces.MessageService
	ModelService                 interfaces.ModelService
	EvaluationService            interfaces.EvaluationService
	KBShareService               interfaces.KBShareService
	AgentShareService            interfaces.AgentShareService
	KBHandler                    *handler.KnowledgeBaseHandler
	GraphSearchHandler           *handler.GraphSearchHandler
	KnowledgeHandler             *handler.KnowledgeHandler
	TenantHandler                *handler.TenantHandler
	TenantService                interfaces.TenantService
	TenantAPIKeyService          interfaces.TenantAPIKeyService
	TenantMemberService          interfaces.TenantMemberService
	TenantMemberHandler          *handler.TenantMemberHandler
	TenantInvitationHandler      *handler.TenantInvitationHandler
	AuditLogHandler              *handler.AuditLogHandler
	AuditLogService              interfaces.AuditLogService
	ChunkHandler                 *handler.ChunkHandler
	SessionHandler               *session.Handler
	MessageHandler               *handler.MessageHandler
	MessageSuggestionHandler     *handler.MessageSuggestionHandler
	ModelHandler                 *handler.ModelHandler
	ModelCredentialsHandler      *handler.ModelCredentialsHandler
	SandboxConfigHandler         *handler.SandboxConfigHandler
	SandboxSkillHandler          *handler.SandboxSkillHandler
	MeEnvVarHandler              *handler.MeEnvVarHandler
	EvaluationHandler            *handler.EvaluationHandler
	AuthHandler                  *handler.AuthHandler
	InitializationHandler        *handler.InitializationHandler
	SystemHandler                *handler.SystemHandler
	MCPServiceHandler            *handler.MCPServiceHandler
	MCPCredentialsHandler        *handler.MCPCredentialsHandler
	MCPOAuthHandler              *handler.MCPOAuthHandler
	WebSearchHandler             *handler.WebSearchHandler
	WebSearchProviderHandler     *handler.WebSearchProviderHandler
	WebSearchCredentialsHandler  *handler.WebSearchProviderCredentialsHandler
	VectorStoreHandler           *handler.VectorStoreHandler
	StorageBackendHandler        *handler.StorageBackendHandler
	StorageBackendResolver       interfaces.StorageBackendResolver
	ResourceCatalog              interfaces.ResourceCatalog
	FAQHandler                   *handler.FAQHandler
	TagHandler                   *handler.TagHandler
	CustomAgentHandler           *handler.CustomAgentHandler
	UserFavoriteHandler          *handler.UserResourceFavoriteHandler
	SkillHandler                 *handler.SkillHandler
	OrganizationHandler          *handler.OrganizationHandler
	IMHandler                    *handler.IMHandler
	EmbedChannelHandler          *handler.EmbedChannelHandler
	EmbedChannelService          interfaces.EmbedChannelService
	MCPEndpointHandler           *handler.MCPEndpointHandler
	MCPEndpointService           interfaces.MCPEndpointService
	MCPServer                    *mcpserver.Server
	RedisClient                  *redis.Client
	DataSourceHandler            *handler.DataSourceHandler
	DataSourceCredentialsHandler *handler.DataSourceCredentialsHandler
	WeKnoraCloudHandler          *handler.WeKnoraCloudHandler
	WikiPageHandler              *handler.WikiPageHandler
	MemoryHandler                *handler.MemoryHandler
	AutomationHandler            *handler.AutomationHandler
	HostSandbox                  service.HostSandboxManager
	OperationDispatcher          *operations.HandlerDispatcher
}

RouterParams 路由参数

type SyncTaskExecutor

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

SyncTaskExecutor executes tasks synchronously (in a goroutine) without Redis. Used in Lite mode as a drop-in replacement for *asynq.Client.

func NewSyncTaskExecutor

func NewSyncTaskExecutor() *SyncTaskExecutor

func (*SyncTaskExecutor) Enqueue

func (e *SyncTaskExecutor) Enqueue(task *asynq.Task, opts ...asynq.Option) (*asynq.TaskInfo, error)

Enqueue satisfies interfaces.TaskEnqueuer. Instead of queuing to Redis, it dispatches the task to a goroutine. Supports ProcessIn / ProcessAt (delay), MaxRetry, Timeout and Deadline for parity with asynq, whether they were given here or to asynq.NewTask.

func (*SyncTaskExecutor) RegisterHandler

func (e *SyncTaskExecutor) RegisterHandler(pattern string, handler func(context.Context, *asynq.Task) error)

RegisterHandler registers a handler for a given task type pattern.

func (*SyncTaskExecutor) SetFinalFailureHook

func (e *SyncTaskExecutor) SetFinalFailureHook(fn func(context.Context, *asynq.Task, error))

SetFinalFailureHook installs the callback run after a task's last failed attempt. It receives the error of that attempt, including asynq.SkipRetry.

type SyncTaskParams

type SyncTaskParams struct {
	dig.In

	Executor             *SyncTaskExecutor
	KnowledgeService     interfaces.KnowledgeService
	KnowledgeBaseService interfaces.KnowledgeBaseService
	TagService           interfaces.KnowledgeTagService
	DataSourceService    interfaces.DataSourceService
	SpanTracker          service.SpanTracker
	ChunkExtractor       interfaces.TaskHandler `name:"chunkExtractor"`
	DataTableSummary     interfaces.TaskHandler `name:"dataTableSummary"`
	ImageMultimodal      interfaces.TaskHandler `name:"imageMultimodal"`
	KnowledgePostProcess interfaces.TaskHandler `name:"knowledgePostProcess"`
	KnowledgeAutoTag     interfaces.TaskHandler `name:"knowledgeAutoTag"`
	KnowledgeBaseProfile interfaces.TaskHandler `name:"knowledgeBaseProfile"`
	WikiIngest           interfaces.TaskHandler `name:"wikiIngest"`
	TemporaryDocument    interfaces.TemporaryDocumentService
	MemoryService        interfaces.MemoryService
}

Jump to

Keyboard shortcuts

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