Documentation
¶
Index ¶
- Constants
- Variables
- func CheckArchiveFolder(archiveFolderPath string) error
- func GetDefaultUser() (string, error)
- func GetInstanceBurstCap(instance string) (int, error)
- func GetInstanceClientID(instance string) (string, error)
- func GetInstanceClientScopes(instance string) (string, error)
- func GetInstanceRateLimit(instance string) (float64, error)
- func GetInstanceScheme(instance string) (string, error)
- func GetUseCleartextFileKeyring() (bool, error)
- func GetUserInstance(user string) (string, error)
- func IsEmpty(folderPath string) (bool, error)
- func KeyringPath() string
- func LoadJSON[T any](path string) (*T, error)
- func PrefsPath() string
- func Ptr[T any](v T) *T
- func ReadCSV(file string) ([][]string, error)
- func RemoveExpectedCSVHeader(expectedHeader []string, rows [][]string) ([][]string, error)
- func SaveJSON(path string, data any) error
- func SavePrefs(prefs *Prefs) error
- func SetDefaultUser(user string) error
- func SetInstanceBurstCap(instance string, burstCap int) error
- func SetInstanceClientID(instance string, clientID string) error
- func SetInstanceClientScopes(instance string, scopes string) error
- func SetInstanceRateLimit(instance string, rateLimit float64) error
- func SetInstanceScheme(instance string, scheme string) error
- func SetUseCleartextFileKeyring(value bool) error
- func SetUserInstance(user string, instance string) error
- func WriteCSV(file string, rows [][]string) error
- type Prefs
- type PrefsInstance
- type PrefsUser
Constants ¶
const DefaultBurstCap int = 10
DefaultBurstCap is the default instance burst capacity. Lower than the GTS default of 300.
const DefaultRateLimit float64 = 0.5
DefaultRateLimit is the default instance rate limit. Lower than the GTS default of 1.0.
const DefaultScheme = "https"
DefaultScheme is the default instance URL scheme.
Variables ¶
var CleartextFileKeyring keyring.Keyring
CleartextFileKeyring stores everything in a cleartext JSON file.
var HttpClient *http.Client
var PrefNotFound = errors.New("preference value not found")
var SystemKeyring keyring.Keyring
SystemKeyring forwards all operations to the go-keyring global system keyring.
var Website = "https://catgirl.codes/slurp"
Functions ¶
func CheckArchiveFolder ¶
func GetDefaultUser ¶
func GetInstanceBurstCap ¶
func GetInstanceClientID ¶
func GetInstanceClientScopes ¶
func GetInstanceRateLimit ¶
func GetInstanceScheme ¶
func GetUserInstance ¶
func KeyringPath ¶
func KeyringPath() string
KeyringPath returns the path to the keyring file, whether or not it exists yet.
func PrefsPath ¶
func PrefsPath() string
PrefsPath returns the path to the preferences file, whether or not it exists yet.
func RemoveExpectedCSVHeader ¶
RemoveExpectedCSVHeader checks that the CSV's header is a non-empty prefix of the expected header, and removes it from the rows.
func SetDefaultUser ¶
func SetInstanceBurstCap ¶
func SetInstanceClientID ¶
func SetInstanceClientScopes ¶
func SetInstanceRateLimit ¶
func SetInstanceScheme ¶
func SetUserInstance ¶
Types ¶
type Prefs ¶
type Prefs struct {
// Instances is a map of instance names to instance preferences.
Instances map[string]PrefsInstance `json:"instances,omitempty"`
// Users is a map of user usernames@domains to instance data.
Users map[string]PrefsUser `json:"users,omitempty"`
// DefaultUser is the username@domain of the last user we successfully authenticated as,
// if there is one.
DefaultUser string `json:"default_user,omitempty"`
// UseCleartextFileKeyring controls whether we use a file-backed keyring instead of a system keyring.
UseCleartextFileKeyring bool `json:"use_cleartext_file_keyring,omitempty"`
}
Prefs stores persisted slurp preferences.
type PrefsInstance ¶
type PrefsInstance struct {
// ClientID is the OAuth2 client ID for slurp on this instance.
ClientID string `json:"client_id,omitempty"`
// Scopes is the OAuth2 scopes this client was created with,
// corresponding to the string oauthScopes in internal/auth/auth.go.
// We use this to check if a previously created client has the right scopes for the current version of slurp.
Scopes string `json:"scopes,omitempty"`
// Scheme is the URL scheme for this instance.
Scheme string `json:"scheme,omitempty"`
// RateLimit is the rate limit for requests to this instance, in requests per second.
RateLimit float64 `json:"rate_limit,omitempty"`
// RateLimit is the burst capacity for requests to this instance, in requests at once.
BurstCap int `json:"burst_cap,omitempty"`
}
PrefsInstance stores preferences for a given instance. OAuth2 app secrets are stored in the system keychain.