Documentation
¶
Index ¶
- Variables
- type ContributorRegistry
- func (r *ContributorRegistry) ContributorCount() int
- func (r *ContributorRegistry) ContributorNames() []string
- func (r *ContributorRegistry) FindContributor(name string) (DashboardContributor, bool)
- func (r *ContributorRegistry) FindLocalContributor(name string) (LocalContributor, bool)
- func (r *ContributorRegistry) FindRemoteContributor(name string) (*RemoteContributor, bool)
- func (r *ContributorRegistry) GetAllSettings() []ResolvedSetting
- func (r *ContributorRegistry) GetAllWidgets() []ResolvedWidget
- func (r *ContributorRegistry) GetManifest(name string) (*Manifest, bool)
- func (r *ContributorRegistry) GetNavGroups() []NavGroup
- func (r *ContributorRegistry) IsLocal(name string) bool
- func (r *ContributorRegistry) IsRemote(name string) bool
- func (r *ContributorRegistry) RebuildNavigation()
- func (r *ContributorRegistry) RegisterLocal(c LocalContributor) error
- func (r *ContributorRegistry) RegisterRemote(c DashboardContributor) error
- func (r *ContributorRegistry) Unregister(name string) error
- type DashboardContributor
- type LocalContributor
- type Manifest
- type NavGroup
- type NavItem
- type NotifiableContributor
- type Notification
- type NotificationDef
- type Params
- type RemoteContributor
- func (rc *RemoteContributor) BaseURL() string
- func (rc *RemoteContributor) FetchPage(ctx context.Context, route string) ([]byte, error)
- func (rc *RemoteContributor) FetchSettings(ctx context.Context, settingID string) ([]byte, error)
- func (rc *RemoteContributor) FetchWidget(ctx context.Context, widgetID string) ([]byte, error)
- func (rc *RemoteContributor) Manifest() *Manifest
- type RemoteContributorOption
- type ResolvedNav
- type ResolvedSetting
- type ResolvedWidget
- type SearchProviderDef
- type SearchResult
- type SearchableContributor
- type SettingsDescriptor
- type WidgetDescriptor
Constants ¶
This section is empty.
Variables ¶
var ( // ErrContributorExists is returned when a contributor with the same name is already registered. ErrContributorExists = errors.New("dashboard: contributor already registered") // ErrContributorNotFound is returned when a contributor is not found in the registry. ErrContributorNotFound = errors.New("dashboard: contributor not found") )
Functions ¶
This section is empty.
Types ¶
type ContributorRegistry ¶
type ContributorRegistry struct {
// contains filtered or unexported fields
}
ContributorRegistry manages all registered contributors and merges their manifests. It is thread-safe for concurrent reads and writes.
func NewContributorRegistry ¶
func NewContributorRegistry() *ContributorRegistry
NewContributorRegistry creates a new empty contributor registry.
func (*ContributorRegistry) ContributorCount ¶
func (r *ContributorRegistry) ContributorCount() int
ContributorCount returns the total number of registered contributors.
func (*ContributorRegistry) ContributorNames ¶
func (r *ContributorRegistry) ContributorNames() []string
ContributorNames returns the names of all registered contributors.
func (*ContributorRegistry) FindContributor ¶
func (r *ContributorRegistry) FindContributor(name string) (DashboardContributor, bool)
FindContributor returns the contributor with the given name.
func (*ContributorRegistry) FindLocalContributor ¶
func (r *ContributorRegistry) FindLocalContributor(name string) (LocalContributor, bool)
FindLocalContributor returns the local contributor with the given name.
func (*ContributorRegistry) FindRemoteContributor ¶
func (r *ContributorRegistry) FindRemoteContributor(name string) (*RemoteContributor, bool)
FindRemoteContributor returns the remote contributor with the given name, type-asserting to *RemoteContributor. Returns false if not found or not a RemoteContributor.
func (*ContributorRegistry) GetAllSettings ¶
func (r *ContributorRegistry) GetAllSettings() []ResolvedSetting
GetAllSettings returns all resolved settings from all contributors. Rebuilds if dirty.
func (*ContributorRegistry) GetAllWidgets ¶
func (r *ContributorRegistry) GetAllWidgets() []ResolvedWidget
GetAllWidgets returns all resolved widgets from all contributors. Rebuilds if dirty.
func (*ContributorRegistry) GetManifest ¶
func (r *ContributorRegistry) GetManifest(name string) (*Manifest, bool)
GetManifest returns the manifest for the named contributor.
func (*ContributorRegistry) GetNavGroups ¶
func (r *ContributorRegistry) GetNavGroups() []NavGroup
GetNavGroups returns the merged navigation groups. Rebuilds if dirty.
func (*ContributorRegistry) IsLocal ¶
func (r *ContributorRegistry) IsLocal(name string) bool
IsLocal returns true if the named contributor is registered as a local contributor.
func (*ContributorRegistry) IsRemote ¶
func (r *ContributorRegistry) IsRemote(name string) bool
IsRemote returns true if the named contributor is registered as a remote contributor.
func (*ContributorRegistry) RebuildNavigation ¶
func (r *ContributorRegistry) RebuildNavigation()
RebuildNavigation merges all manifests into NavGroups, sorted by priority. This must be called explicitly after registrations are complete, or it will be called lazily by GetNavGroups if the registry is dirty.
func (*ContributorRegistry) RegisterLocal ¶
func (r *ContributorRegistry) RegisterLocal(c LocalContributor) error
RegisterLocal registers a local (in-process) contributor.
func (*ContributorRegistry) RegisterRemote ¶
func (r *ContributorRegistry) RegisterRemote(c DashboardContributor) error
RegisterRemote registers a remote (over-the-network) contributor.
func (*ContributorRegistry) Unregister ¶
func (r *ContributorRegistry) Unregister(name string) error
Unregister removes a contributor by name (local or remote).
type DashboardContributor ¶
type DashboardContributor interface {
// Manifest returns the contributor's manifest describing its pages, widgets, settings, etc.
Manifest() *Manifest
}
DashboardContributor is the base interface every dashboard extension implements. It provides a manifest describing the contributor's capabilities.
type LocalContributor ¶
type LocalContributor interface {
DashboardContributor
// RenderPage renders a page for the given route.
RenderPage(ctx context.Context, route string, params Params) (g.Node, error)
// RenderWidget renders a specific widget by ID.
RenderWidget(ctx context.Context, widgetID string) (g.Node, error)
// RenderSettings renders a settings panel for the given setting ID.
RenderSettings(ctx context.Context, settingID string) (g.Node, error)
}
LocalContributor runs in-process and renders gomponents.Node directly. This is the primary interface for extensions that contribute UI to the dashboard.
type Manifest ¶
type Manifest struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
Icon string `json:"icon"`
Version string `json:"version"`
Layout string `json:"layout,omitempty"` // "dashboard", "settings", "base", "full" — default "dashboard"
Widgets []WidgetDescriptor `json:"widgets"`
Settings []SettingsDescriptor `json:"settings"`
SearchProviders []SearchProviderDef `json:"search_providers,omitempty"`
Notifications []NotificationDef `json:"notifications,omitempty"`
Capabilities []string `json:"capabilities,omitempty"`
}
Manifest describes a contributor's capabilities, navigation, widgets, settings, and more.
type NavGroup ¶
type NavGroup struct {
}
NavGroup is a merged sidebar section built from contributor manifests.
type NavItem ¶
type NavItem struct {
}
NavItem represents a navigation entry in the dashboard sidebar.
type NotifiableContributor ¶
type NotifiableContributor interface {
DashboardContributor
// Notifications returns a channel that emits notifications.
// The channel should be closed when the context is cancelled.
Notifications(ctx context.Context) (<-chan Notification, error)
}
NotifiableContributor optionally streams notifications from a contributor.
type Notification ¶
type Notification struct {
ID string `json:"id"`
Source string `json:"source"`
Message string `json:"message"`
Severity string `json:"severity"`
URL string `json:"url,omitempty"`
Time int64 `json:"time"` // unix timestamp
}
Notification represents a real-time notification from a contributor.
type NotificationDef ¶
type NotificationDef struct {
ID string `json:"id"`
Name string `json:"name"`
Severity string `json:"severity"` // "info", "warning", "error", "critical"
}
NotificationDef describes a notification type an extension can emit.
type Params ¶
type Params struct {
Route string
PathParams map[string]string
QueryParams map[string]string
FormData map[string]string
}
Params holds route parameters and query strings extracted from the request.
type RemoteContributor ¶
type RemoteContributor struct {
// contains filtered or unexported fields
}
RemoteContributor wraps a remote service that exposes dashboard pages and widgets via HTTP fragment endpoints. It fetches HTML fragments from the remote service and returns them as raw HTML nodes for embedding in the dashboard shell.
func NewRemoteContributor ¶
func NewRemoteContributor(baseURL string, manifest *Manifest, opts ...RemoteContributorOption) *RemoteContributor
NewRemoteContributor creates a remote contributor from a base URL and manifest.
func (*RemoteContributor) BaseURL ¶
func (rc *RemoteContributor) BaseURL() string
BaseURL returns the remote service base URL.
func (*RemoteContributor) FetchPage ¶
FetchPage fetches an HTML page fragment from the remote service.
func (*RemoteContributor) FetchSettings ¶
FetchSettings fetches an HTML settings form from the remote service.
func (*RemoteContributor) FetchWidget ¶
FetchWidget fetches an HTML widget fragment from the remote service.
func (*RemoteContributor) Manifest ¶
func (rc *RemoteContributor) Manifest() *Manifest
Manifest returns the contributor's manifest.
type RemoteContributorOption ¶
type RemoteContributorOption func(*RemoteContributor)
RemoteContributorOption configures a RemoteContributor.
func WithAPIKey ¶
func WithAPIKey(key string) RemoteContributorOption
WithAPIKey sets the API key for authenticating with the remote service.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) RemoteContributorOption
WithHTTPClient sets a custom HTTP client for the remote contributor.
type ResolvedNav ¶
type ResolvedNav struct {
}
ResolvedNav is a NavItem enriched with its owning contributor name and resolved path.
type ResolvedSetting ¶
type ResolvedSetting struct {
SettingsDescriptor
Contributor string
}
ResolvedSetting is a SettingsDescriptor enriched with its owning contributor name.
type ResolvedWidget ¶
type ResolvedWidget struct {
WidgetDescriptor
Contributor string
}
ResolvedWidget is a WidgetDescriptor enriched with its owning contributor name.
type SearchProviderDef ¶
type SearchProviderDef struct {
ID string `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix,omitempty"` // e.g., "user:" filters to this provider
ResultTypes []string `json:"result_types,omitempty"` // "page", "entity", "action"
}
SearchProviderDef describes a search provider contributed by an extension.
type SearchResult ¶
type SearchResult struct {
Title string `json:"title"`
Description string `json:"description"`
URL string `json:"url"`
Icon string `json:"icon"`
Source string `json:"source"` // contributor name
Category string `json:"category"`
Score float64 `json:"score"`
}
SearchResult represents a single search result from a contributor.
type SearchableContributor ¶
type SearchableContributor interface {
DashboardContributor
// Search performs a search query and returns matching results.
Search(ctx context.Context, query string, limit int) ([]SearchResult, error)
}
SearchableContributor optionally adds search capability to a contributor.
type SettingsDescriptor ¶
type SettingsDescriptor struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Group string `json:"group"`
Icon string `json:"icon"`
Priority int `json:"priority"`
}
SettingsDescriptor describes a settings panel contributed by an extension.
type WidgetDescriptor ¶
type WidgetDescriptor struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
Size string `json:"size"` // "sm", "md", "lg"
RefreshSec int `json:"refresh_sec"` // 0 = static
Group string `json:"group"`
Priority int `json:"priority"`
}
WidgetDescriptor describes a widget that can be rendered on the dashboard.