import {
  applySliceAllHosts,
  applySliceHost,
  buildSliceApplyScript,
  buildSliceVerifyLines,
  sliceDescriptor,
  sliceUnitBody,
} from "./systemd-slice.mjs";

export const AGENT_RUN_SLICE = "agent-run.slice";

export const AGENT_RUN_SLICE_DESCRIPTOR = sliceDescriptor({
  unit: AGENT_RUN_SLICE,
  label: "agent-run-slice",
  show: {
    MemoryMax: "8589934592",
    MemorySwapMax: "1073741824",
    CPUQuotaPerSecUSec: "4s",
    CPUWeight: "1",
    TasksMax: "1024",
  },
});

export const AGENT_RUN_SLICE_SRC_REL = AGENT_RUN_SLICE_DESCRIPTOR.srcRel;
export const AGENT_RUN_SLICE_DST_REL = AGENT_RUN_SLICE_DESCRIPTOR.dstRel;
export const AGENT_RUN_SLICE_REPO_PATH = AGENT_RUN_SLICE_DESCRIPTOR.repoPath;
export const AGENT_RUN_SLICE_SHOW = AGENT_RUN_SLICE_DESCRIPTOR.show;

export function agentRunSliceUnitBody(path = AGENT_RUN_SLICE_REPO_PATH) {
  return sliceUnitBody(AGENT_RUN_SLICE_DESCRIPTOR, path);
}

export function buildAgentRunSliceVerifyLines(opts = {}) {
  return buildSliceVerifyLines(AGENT_RUN_SLICE_DESCRIPTOR, opts);
}

export function buildAgentRunSliceApplyScript() {
  return buildSliceApplyScript(AGENT_RUN_SLICE_DESCRIPTOR);
}

export function applyAgentRunSliceHost(cfg, deps = {}) {
  return applySliceHost(AGENT_RUN_SLICE_DESCRIPTOR, cfg, deps);
}

export function applyAgentRunSliceAllHosts(cfg, opts = {}, deps = {}) {
  return applySliceAllHosts(AGENT_RUN_SLICE_DESCRIPTOR, cfg, opts, deps);
}
