client

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

Pylon Go Client

Go client library for the Pylon service registry.

go get github.com/Work-Fort/Pylon/client/go

See requirements for full API documentation.

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

Package client provides a typed Go client for the Pylon service registry. It connects to Pylon's HTTP API to discover WorkFort services at runtime.

Usage:

c := client.New("http://pylon:18000", serviceAPIKey)
svc, err := c.ServiceByName(ctx, "hive")
if err != nil { log.Fatal(err) }
hiveClient := hive.New(svc.BaseURL, serviceAPIKey)

SPDX-License-Identifier: Apache-2.0

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned by ServiceByName when the named service
	// is not in the registry.
	ErrNotFound = errors.New("service not found")

	// ErrUnauthorized is returned when Pylon responds with 401.
	ErrUnauthorized = errors.New("unauthorized")

	// ErrForbidden is returned when Pylon responds with 403.
	ErrForbidden = errors.New("forbidden")
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	// contains filtered or unexported fields
}

APIError is returned for non-2xx HTTP responses from Pylon.

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap allows errors.Is to match sentinel errors.

type Client

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

Client is an HTTP client for the Pylon service registry API.

func New

func New(pylonURL, apiKey string) *Client

New creates a Pylon client that authenticates with a Passport API key (Authorization: ApiKey-v1 <key>). API keys are recognizable by the wf-agent_ or wf-svc_ prefix.

Pylon's outbound clients are API-key-only — JWTs are reserved for browser-routed traffic which never originates here.

func (*Client) ServiceByName

func (c *Client) ServiceByName(ctx context.Context, name string) (*Service, error)

ServiceByName returns a specific service by its registered name. Returns ErrNotFound if the service is not in the registry.

func (*Client) Services

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

Services returns all registered services from Pylon.

type Service

type Service struct {
	Name             string   `json:"name"`
	Label            string   `json:"label"`
	Route            string   `json:"route"`
	BaseURL          string   `json:"base_url"`
	UI               bool     `json:"ui"`
	Connected        bool     `json:"connected"`
	SetupMode        bool     `json:"setup_mode"`
	AdminOnly        bool     `json:"admin_only"`
	Display          string   `json:"display"`
	WSPaths          []string `json:"ws_paths"`
	NotificationPath *string  `json:"notification_path,omitempty"`
}

Service represents a discovered WorkFort service.

Jump to

Keyboard shortcuts

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