sdk

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 10 Imported by: 0

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

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

func New(cfg Config) (*Client, error)

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

func (c *Client) Deregister(ctx context.Context) error

Deregister stops the heartbeat and removes this service from Pulse.

func (*Client) DiscoverAll

func (c *Client) DiscoverAll(ctx context.Context) ([]Service, error)

DiscoverAll returns all registered services.

func (*Client) DiscoverByCapability

func (c *Client) DiscoverByCapability(ctx context.Context, capability string) ([]Service, error)

DiscoverByCapability returns all services declaring a given capability.

func (*Client) DiscoverByType

func (c *Client) DiscoverByType(ctx context.Context, serviceType string) ([]Service, error)

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

func (c *Client) MyIndexers(ctx context.Context) ([]Indexer, error)

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.

func (*Client) ServiceID

func (c *Client) ServiceID() string

ServiceID returns the ID assigned by Pulse during registration.

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 {
	ColonReplacement    string `json:"colon_replacement"`
	ImportExtraFiles    bool   `json:"import_extra_files"`
	ExtraFileExtensions string `json:"extra_file_extensions"`
	RenameFiles         bool   `json:"rename_files"`
	UpdatedAt           string `json:"updated_at"`
}

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.

Jump to

Keyboard shortcuts

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