Documentation
¶
Overview ¶
Package sdk provides a Go client for ecosystem services to register with Pulse, send heartbeats, discover peers, and pull managed resources (indexers, download clients, quality profiles, shared settings).
Usage:
client, err := sdk.New(sdk.Config{
PulseURL: "http://pulse:9696",
APIKey: "your-api-key",
ServiceName: "luminarr",
ServiceType: "media-manager",
APIURL: "http://luminarr:8282",
HealthURL: "http://luminarr:8282/health",
Version: "0.1.0",
Capabilities: []string{"supports_torrent", "supports_usenet"},
})
defer client.Close()
The client auto-registers on creation and sends heartbeats at a configurable interval. Call Discover/Config methods to query the control plane.
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) Deregister(ctx context.Context) error
- func (c *Client) DiscoverAll(ctx context.Context) ([]Service, error)
- func (c *Client) DiscoverByCapability(ctx context.Context, capability string) ([]Service, error)
- func (c *Client) DiscoverByType(ctx context.Context, serviceType string) ([]Service, error)
- func (c *Client) MyDownloadClients(ctx context.Context) ([]DownloadClient, error)
- func (c *Client) MyIndexers(ctx context.Context) ([]Indexer, error)
- func (c *Client) MyQualityProfiles(ctx context.Context) ([]QualityProfile, error)
- func (c *Client) MySharedSettings(ctx context.Context) (*SharedSettings, error)
- func (c *Client) ServiceID() string
- type Config
- type DownloadClient
- type Indexer
- type QualityProfile
- type Service
- type SharedSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Pulse SDK client. Create one with New().
func New ¶
New creates a new SDK client, registers the service with Pulse, and starts the heartbeat loop. Call Close() to stop the heartbeat and deregister (optional).
func (*Client) Close ¶
func (c *Client) Close()
Close stops the heartbeat loop. It does NOT deregister — the service remains registered so Pulse can track it went offline via health checks.
func (*Client) Deregister ¶
Deregister stops the heartbeat and removes this service from Pulse.
func (*Client) DiscoverAll ¶
DiscoverAll returns all registered services.
func (*Client) DiscoverByCapability ¶
DiscoverByCapability returns all services declaring a given capability.
func (*Client) DiscoverByType ¶
DiscoverByType returns all services of a given type (e.g. "download-client").
func (*Client) MyDownloadClients ¶
func (c *Client) MyDownloadClients(ctx context.Context) ([]DownloadClient, error)
MyDownloadClients returns download clients available to this service.
func (*Client) MyIndexers ¶
MyIndexers returns the indexers assigned to this service by Pulse.
func (*Client) MyQualityProfiles ¶
func (c *Client) MyQualityProfiles(ctx context.Context) ([]QualityProfile, error)
MyQualityProfiles returns quality profiles available to this service. Services call this on their sync loop to receive centrally managed profiles.
func (*Client) MySharedSettings ¶
func (c *Client) MySharedSettings(ctx context.Context) (*SharedSettings, error)
MySharedSettings returns the shared media handling settings from Pulse.
type Config ¶
type Config struct {
// PulseURL is the base URL of the Pulse instance (e.g. "http://pulse:9696").
PulseURL string
// APIKey is the Pulse API key for authentication.
APIKey string
// ServiceName is the name this service registers under (e.g. "luminarr").
ServiceName string
// ServiceType categorizes the service (e.g. "media-manager", "download-client").
ServiceType string
// APIURL is the URL where this service's API is reachable.
APIURL string
// HealthURL is the URL for health checks. Optional.
HealthURL string
// Version is the service version string. Optional.
Version string
// Capabilities declares what this service supports. Optional.
Capabilities []string
// HeartbeatInterval controls how often heartbeats are sent. Default: 30s.
HeartbeatInterval time.Duration
// Logger is an optional structured logger. Falls back to slog.Default().
Logger *slog.Logger
// HTTPClient is an optional custom HTTP client. Falls back to http.DefaultClient.
HTTPClient *http.Client
}
Config holds the settings for connecting to Pulse.
type DownloadClient ¶
type DownloadClient struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"` // qbittorrent, deluge, transmission, sabnzbd, nzbget
Protocol string `json:"protocol"` // torrent, usenet
Enabled bool `json:"enabled"`
Priority int `json:"priority"`
Host string `json:"host"`
Port int `json:"port"`
UseSSL bool `json:"use_ssl"`
Username string `json:"username"`
Category string `json:"category"`
Directory string `json:"directory"`
Settings string `json:"settings"`
}
DownloadClient represents a centrally managed download client.
type Indexer ¶
type Indexer struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Enabled bool `json:"enabled"`
Priority int `json:"priority"`
URL string `json:"url"`
Settings string `json:"settings"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Indexer represents an indexer assigned to this service.
type QualityProfile ¶
type QualityProfile struct {
ID string `json:"id"`
Name string `json:"name"`
CutoffJSON string `json:"cutoff_json"`
QualitiesJSON string `json:"qualities_json"`
UpgradeAllowed bool `json:"upgrade_allowed"`
UpgradeUntilJSON *string `json:"upgrade_until_json,omitempty"`
MinCustomFormatScore int `json:"min_custom_format_score"`
UpgradeUntilCFScore int `json:"upgrade_until_cf_score"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
QualityProfile represents a centrally managed quality profile pushed from Pulse. The JSON blob fields (CutoffJSON, QualitiesJSON, UpgradeUntilJSON) are opaque to Pulse — consumers parse them into their own domain types.
type Service ¶
type Service struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
APIURL string `json:"api_url"`
HealthURL string `json:"health_url"`
Version string `json:"version"`
Status string `json:"status"`
LastSeen string `json:"last_seen"`
Registered string `json:"registered"`
Capabilities []string `json:"capabilities"`
}
Service represents a registered service returned by discovery queries.
type SharedSettings ¶
type SharedSettings struct {
}
SharedSettings is the filesystem/handling settings that apply uniformly across all media-manager services. Services overlay these onto their local media_management row on every sync tick.