annals.target#
The transport seam: a document tree lands in a directory, here or on another machine.
A Target is the handful of filesystem verbs the store needs (put a directory, move,
remove, read and write a text file, list sub-directories, read every meta.json under a
directory). Two implementations:
LocalTarget: a directory on this machine, plainpathlib/shutil.SshTarget:host:pathon another machine, through the systemsshandrsyncin batch mode (no prompts, so an agent never hangs). The host is whatever the user’s~/.ssh/configresolves, so an alias such astwworks.
parse_target() picks one from a string. An HTTP target (a bearer-token ingest
endpoint) is the declared replacement for the ssh one and is not built yet.
Module Attributes
Separator between concatenated meta.json files when reading many at once over ssh. |
|
each document's meta.json |
|
the note a lock directory is created with (see |
|
the several calls of one command (and the next command soon after) reuse it instead of paying a handshake each (~3 s to a far host) |
Functions
|
A glob safe to hand a remote shell unquoted: names, |
|
Refuse anything that could escape the root; the store only ever passes safe paths. |
|
|
|
The ssh options: batch mode, and one connection shared by consecutive calls. |
Classes
|
A directory on this machine. |
|
|
|
What the store needs from wherever the documents live. |
- annals.target.LOCK_NOTE = 'lock.json'#
the note a lock directory is created with (see
Target.make_lock())
- annals.target.META_GLOB = '*/meta.json'#
each document’s meta.json
- Type:
what
Target.read_metas()reads by default
- annals.target.RECORD_SEP = '\x1e'#
Separator between concatenated meta.json files when reading many at once over ssh.
- annals.target.SSH_SHARE_S = 60#
the several calls of one command (and the next command soon after) reuse it instead of paying a handshake each (~3 s to a far host)
- Type:
how long the shared ssh connection outlives its last use
- class annals.target.SshTarget(host, root)[source]#
Bases:
objecthost:pathon another machine, via the system ssh and rsync in batch mode.
- class annals.target.Target(*args, **kwargs)[source]#
Bases:
ProtocolWhat the store needs from wherever the documents live.
- local_path(rel)[source]#
The file on this machine’s disk, when the documents are local (to stream it).
- make_lock(rel, note)[source]#
Create directory
relholdinglock.json(note) as one step; fail if it exists. An atomic test-and-set: a lock that is never seen without its note.- Return type:
- annals.target.check_glob(pattern)[source]#
A glob safe to hand a remote shell unquoted: names,
*and/only, no hidden part.- Return type:
- annals.target.check_rel(rel)[source]#
Refuse anything that could escape the root; the store only ever passes safe paths.
- Return type:
- annals.target.parse_target(spec)[source]#
host:/pathbecomes anSshTarget; anything else aLocalTarget.- Return type: