Documentation
¶
Overview ¶
Package origin is the single owner of "this workspace's origin clients".
Production code constructs a *jira.Client only through Client (the workspace's origin) or Connected (a candidate site/email/token, used when verifying a credential the user just typed). The wiki client is Wiki — the same split (standalone in-process handler vs connected site). jira.New stays exported for tests that stand up httptest servers; a gate test fails if production files grow a new direct call.
Index ¶
- Constants
- func AdvertisePath(dir string) string
- func Client(cfg *config.Config) (*jira.Client, error)
- func Close() error
- func Connected(site, email, token string) *jira.Client
- func DefaultConfluenceConfig() *config.ConfluenceConfig
- func Describe(cfg *config.Config) (kind, origin string)
- func ForgetLive()
- func OwnerStatus(cfg *config.Config) string
- func PersistPath(dir string) string
- func RemoveAdvertise(dir string) error
- func SessionInFlight() int64
- func SessionsConstructed() uint64
- func SessionsDiscarded() uint64
- func SetInProcess(v bool)
- func StandaloneHandler(cfg *config.Config) (http.Handler, error)
- func TransportIsEmbedded(rt http.RoundTripper) bool
- func TransportIsServe(rt http.RoundTripper) bool
- func Wiki(cfg *config.Config) (*confluence.Client, error)
- func WriteAdvertise(dir, addr string) error
- type Advertise
Constants ¶
const AdvertiseRel = "serve-origin.json"
AdvertiseRel is the profile-relative runtime file a standalone serve writes so other processes can find the persist owner. Connected workspaces never write it.
const DefaultProjectKey = "STD"
DefaultProjectKey is the project seeded into a new standalone origin so create/createmeta have somewhere to file. Issuetap also creates a project on first write if a caller names another key.
const DefaultSpaceKey = "LOC"
DefaultSpaceKey is the wiki space seeded into a new standalone origin so page create has somewhere to file. Short and obviously local — not a display name, and not a site-specific key.
const PersistRel = "origin/issuetap.yaml"
PersistRel is the workspace-relative path of the issuetap write-through snapshot. The file is the origin; the SQLite mirror remains a disposable cache filled by sync.
const RESTPrefix = "/api/v1/origin"
RESTPrefix is the serve passthrough root. A client request to /rest/api/3/issue is sent to <serve> + RESTPrefix + /rest/api/3/issue.
Variables ¶
This section is empty.
Functions ¶
func AdvertisePath ¶
AdvertisePath is the absolute runtime-file path inside a profile directory.
func Client ¶
Client is the single owner of "this workspace's Jira client". A connected workspace gets the same jira.New(site, email, token) as before. A standalone workspace gets a client whose Transport is the in-process issuetap handler, unless a live `gadak serve` for this profile advertised itself — then Transport is that serve's origin passthrough so persist has one owner. BaseURL stays empty so stored browse links are /browse/KEY rather than a fake https origin a person might click.
func Close ¶
func Close() error
Close flushes every live standalone origin and drops the sessions. Safe to call more than once. The process owner (cmd/gadak main) calls this on the way out so the last PersistDebounce window is not lost.
In-flight constructors are waited on (they publish, then this snapshots) so Close never closes a half-built Embedded. There is no permanent closed flag: Client after Close must open a new session (persist is the origin; the process is allowed to come back).
func Connected ¶
Connected builds a client for an explicit site/email/token — verifying a credential the user just typed, not "this workspace's origin".
func DefaultConfluenceConfig ¶
func DefaultConfluenceConfig() *config.ConfluenceConfig
DefaultConfluenceConfig is what initStandalone writes so the wiki sync pass is on and scoped to the seeded space. Presence of the block is the on switch (internal/sync/confluence.go).
func Describe ¶
Describe answers doctor: which kind of workspace, and where the origin is. Connected reports "jira" (no hostname — doctor is safe to paste). Standalone reports the persist path.
func ForgetLive ¶
func ForgetLive()
ForgetLive drops cached embedded sessions without closing them. Tests use this to simulate a second process: the serve handler still holds the graph, but Client no longer finds it in this process.
func OwnerStatus ¶
OwnerStatus is the doctor line: "serve pid=… addr=…" or "embedded (no live serve)". Empty when the workspace is not standalone.
func PersistPath ¶
PersistPath is the absolute issuetap snapshot path inside a profile directory.
func RemoveAdvertise ¶
RemoveAdvertise deletes the runtime file. Missing is not an error — crash leftover is the other path, and the next probe treats a dead file as "no live serve".
func SessionInFlight ¶
func SessionInFlight() int64
SessionInFlight is how many standaloneSession constructions are running outside mu. Same shape as store.WriteBusyRetries: a cheap accessor, no logs.
func SessionsConstructed ¶
func SessionsConstructed() uint64
SessionsConstructed is how many times constructStandalone ran. Tests use a delta to prove a routed Client did not open a second persist graph.
func SessionsDiscarded ¶
func SessionsDiscarded() uint64
SessionsDiscarded is how many constructed sessions lost the publish race and were closed. Same shape as store.WriteBusyRetries.
func SetInProcess ¶
func SetInProcess(v bool)
SetInProcess marks this process as the persist owner (`gadak serve` on a standalone workspace). Client and Wiki then always use the embedded session and never proxy to the advertise file — that would loop back onto this same listener.
func StandaloneHandler ¶
StandaloneHandler is the in-process issuetap HTTP surface for this workspace. Serve's origin passthrough uses it so CLI writes land on the same graph the UI already holds. Always embeds — never routes — so the serve process cannot proxy to itself through this entry.
func TransportIsEmbedded ¶
func TransportIsEmbedded(rt http.RoundTripper) bool
TransportIsEmbedded reports whether c talks to an in-process issuetap handler. Tests use this instead of naming the unexported type.
func TransportIsServe ¶
func TransportIsServe(rt http.RoundTripper) bool
TransportIsServe reports whether c talks to a live serve passthrough.
func Wiki ¶
func Wiki(cfg *config.Config) (*confluence.Client, error)
Wiki is the single owner of "this workspace's Confluence client". A connected workspace gets confluence.New(site, email, token). A standalone workspace shares the in-process issuetap handler with Client.
func WriteAdvertise ¶
WriteAdvertise publishes the final listen address of a standalone serve. Atomic write (temp + rename) at 0600, same as config.Save.