Help us shape the future of Go! Take the 2026 Go Developer Survey

upstream

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package upstream provides HTTP helpers for fetching workspace-scoped data from the rysh-server using the local upstream API key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchWorkspaceID

func FetchWorkspaceID(up config.UpstreamConfig) (string, error)

FetchWorkspaceID is FetchWorkspaceInfo when only the namespace token matters.

func ResolveWorkspaceID

func ResolveWorkspaceID(up config.UpstreamConfig) string

ResolveWorkspaceID returns the upstream NATS namespace token for the given upstream config. When the configured workspace value is already a UUID it is returned unchanged (no network call). Otherwise — when sharing is enabled and an api_key is present — it resolves the workspace id from the server via the api key. On any failure it falls back to the configured value so the CLI still starts (sharing simply won't line up until the id is correct).

Types

type ConnectionCredentials

type ConnectionCredentials struct {
	ConnectionID   string            `json:"connection_id"`
	WorkspaceID    string            `json:"workspace_id"`
	Name           string            `json:"name"`
	ConnectionType string            `json:"connection_type"`
	Config         map[string]string `json:"config"`
	Secrets        map[string]string `json:"secrets"`
}

ConnectionCredentials carries decrypted secrets plus public config for an external connection of a given type, fetched from the rysh-server.

func FetchConnectionCredentials

func FetchConnectionCredentials(cfg config.Config, connType string) (*ConnectionCredentials, error)

FetchConnectionCredentials retrieves the decrypted credentials for the workspace's enabled connection of the given type (e.g. "slack", "whatsapp"). Returns an error if upstream is not configured, the request fails, or the workspace has no enabled connection of that type.

type RemoteShare

type RemoteShare struct {
	ID          string `json:"id"`
	ShareID     string `json:"share_id"`
	EntityType  string `json:"entity_type"`
	EntityID    string `json:"entity_id"`
	EntityAlias string `json:"entity_alias"`
	ShareMode   string `json:"share_mode"`
	State       string `json:"state"`
	Origin      string `json:"origin"`
	SessionName string `json:"session_name"`
	CreatedAt   string `json:"created_at"`
}

RemoteShare represents a shared entity returned by the upstream server.

func FetchRemoteShares

func FetchRemoteShares(cfg config.Config) ([]RemoteShare, error)

FetchRemoteShares retrieves all active shares in the workspace from the upstream server. The workspace API key scopes the query to the key's workspace only.

type WorkspaceInfo added in v0.2.4

type WorkspaceInfo struct {
	Name string
	ID   string
}

WorkspaceInfo is what /api/server-info tells a client about the workspace its API key belongs to: the Name a human recognises, and the ID that is the only thing usable on the wire.

func FetchWorkspaceInfo added in v0.2.4

func FetchWorkspaceInfo(up config.UpstreamConfig) (WorkspaceInfo, error)

FetchWorkspaceInfo queries the upstream server's /api/server-info endpoint with the workspace API key and returns the workspace name and id (UUID). The id is the globally unique NATS namespace token (ws.{id}.*); workspace names are unique per user, so the name cannot be used on the wire.

Its errors are written for a human to read as one line — `##upstream connect` prints them verbatim. A user who mistyped a URL should see that, not a wrapped *url.Error with an HTTP body glued to the end of it.

Jump to

Keyboard shortcuts

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