sysapproach

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package sysapproach is the library behind the sysapproach CLI.

Index

Constants

View Source
const DefaultUserAgent = "sysapproach-cli/dev (+https://github.com/tamnd/sysapproach-cli)"

DefaultUserAgent identifies the client to the server. An honest User-Agent is both polite and the thing most likely to keep a session unblocked.

View Source
const Host = "book.systemsapproach.org"

Host is the canonical hostname of the book site.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chapter

type Chapter struct {
	Rank   int    `json:"rank"   csv:"rank"   tsv:"rank"`
	Number int    `json:"number" csv:"number" tsv:"number"`
	Title  string `json:"title"  csv:"title"  tsv:"title"`
	URL    string `json:"url"    csv:"url"    tsv:"url"`
}

Chapter is one chapter of Computer Networks: A Systems Approach.

type Client

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

Client talks to book.systemsapproach.org over HTTPS.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client using cfg.

func (*Client) Chapters

func (c *Client) Chapters(ctx context.Context) ([]*Chapter, error)

Chapters fetches the home page and returns the book's chapters sorted by chapter number. Duplicate links (Sphinx repeats chapter links in the sidebar and in the main table of contents) are deduplicated by chapter number.

type Config

type Config struct {
	BaseURL   string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
	UserAgent string
}

Config holds per-client tunables, all of which have sane defaults.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with polite, safe defaults.

type Domain

type Domain struct{}

Domain is the sysapproach driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

type Page

type Page struct {
	ID    string `json:"id" kit:"id"`
	URL   string `json:"url"`
	Title string `json:"title,omitempty"`
	Body  string `json:"body,omitempty" kit:"body"`
}

Page is a generic page record used by the page/links ops.

Jump to

Keyboard shortcuts

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