pub struct ForgeService { /* private fields */ }Expand description
The forge service. One instance is built at server startup and shared
(Arc) across requests. All durable state lives under plugin_dir.
Implementations§
Source§impl ForgeService
impl ForgeService
Sourcepub async fn label_defs(
&self,
owner: &str,
repo: &str,
) -> Result<Vec<Label>, ForgeError>
pub async fn label_defs( &self, owner: &str, repo: &str, ) -> Result<Vec<Label>, ForgeError>
Sourcepub async fn put_item_labels(
&self,
req: &ForgeRequest,
agent: &ForgeAgent,
owner: &str,
repo: &str,
number: u64,
kind: ItemKind,
) -> Result<ForgeResponse, ForgeError>
pub async fn put_item_labels( &self, req: &ForgeRequest, agent: &ForgeAgent, owner: &str, repo: &str, number: u64, kind: ItemKind, ) -> Result<ForgeResponse, ForgeError>
PUT …/{issues,pulls}/<n>/labels {labels: [names]}: replace an item’s
label set. Repo owner or the item’s author; every name must exist in
the repo’s label set (names are validated, never invented).
Pull-request routes call this with ItemKind::Pull.
§Errors
Spine I/O and corruption errors; request problems are returned as
Ok JSON error responses (401, 400, 422, 404, 403).
Source§impl ForgeService
impl ForgeService
Sourcepub fn merge_tree_ok(&self) -> bool
pub fn merge_tree_ok(&self) -> bool
Is merge-tree --write-tree available on this host?
Sourcepub fn with_git_version(self, version: &str) -> Self
pub fn with_git_version(self, version: &str) -> Self
Pin the git version string used for the 2.38 gate (the default is the installed git, detected once at start-up). Operators and tests use this to force the “git too old” path.
Sourcepub fn with_tip_recorder(self, rec: Arc<dyn TipRecorder>) -> Self
pub fn with_tip_recorder(self, rec: Arc<dyn TipRecorder>) -> Self
Install the TipRecorder called after every successful merge.
Source§impl ForgeService
impl ForgeService
Sourcepub fn with_pull_labels(self, labels: Arc<dyn PullLabels>) -> Self
pub fn with_pull_labels(self, labels: Arc<dyn PullLabels>) -> Self
Install the label resolver for pull requests (integration point).
Source§impl ForgeService
impl ForgeService
Sourcepub fn new(
cfg: ForgeConfig,
plugin_dir: impl Into<PathBuf>,
) -> Result<Self, ForgeError>
pub fn new( cfg: ForgeConfig, plugin_dir: impl Into<PathBuf>, ) -> Result<Self, ForgeError>
Build a forge rooted at plugin_dir. Creates the on-disk layout
(repos/, issues/, pulls/, hosted/, marks/) if absent.
The git CGI service is rooted at plugin_dir/repos.
Sourcepub fn locks(&self) -> &ForgeLocks
pub fn locks(&self) -> &ForgeLocks
The per-repository spine locks. Hold an issue lock across the
load-modify-save of issues/<owner>/<repo>.json and a pull lock across
the same for the pulls index and merges; when both are needed take the
issue lock first. See locks.
Sourcepub fn config(&self) -> &ForgeConfig
pub fn config(&self) -> &ForgeConfig
The service configuration.
Sourcepub fn with_loopback(self, lb: Arc<dyn LoopbackFetch>) -> Self
pub fn with_loopback(self, lb: Arc<dyn LoopbackFetch>) -> Self
Inject the loopback fetcher (the server’s reqwest client) used to verify and re-fetch pod-hosted bodies.
Sourcepub fn with_spine(self, spine: Arc<dyn SpineStore>) -> Self
pub fn with_spine(self, spine: Arc<dyn SpineStore>) -> Self
Override the spine store (tests inject an in-memory store).
Sourcepub fn token_key(&self) -> &[u8; 32]
pub fn token_key(&self) -> &[u8; 32]
The forge instance HMAC key (for token minting/verification).
Sourcepub async fn resolve_agent(&self, req: &ForgeRequest) -> ForgeAgent
pub async fn resolve_agent(&self, req: &ForgeRequest) -> ForgeAgent
Resolve the caller identity from req’s Authorization header
(forge token or NIP-98). The server may instead pass a
ForgeAgent::Pod directly to Self::handle when it has a pod
session; this helper is for the token/NIP-98 schemes.
Sourcepub fn plugin_dir(&self) -> &Path
pub fn plugin_dir(&self) -> &Path
The plugin data directory.
Sourcepub async fn handle(
&self,
req: ForgeRequest,
agent: ForgeAgent,
) -> Result<ForgeResponse, ForgeError>
pub async fn handle( &self, req: ForgeRequest, agent: ForgeAgent, ) -> Result<ForgeResponse, ForgeError>
Single entry point. The embedding server maps its native request
to a ForgeRequest, WAC-gates the scope, and calls this.