研究预算
原能力
管理共享研究预算、费用预留和累计用量,重试和换模型不得重置已发生费用。(合同附件 R7 6.5)
首选项目
Formance Ledger(MIT)。 Formance Ledger
接入说明
首选 Formance 记预算及费用,Temporal 负责活动调用。预算适用范围和扣减规则需要适配。
匹配范围
持久流程与分录记录预算预留及累积费用。
源码
Formance Ledger · func (s *Server) handleCreateTransaction(
internal/adapter/http/handlers_create_transaction.go · 13–26 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
func (s *Server) handleCreateTransaction(w http.ResponseWriter, r *http.Request) {
ledgerName, ok := requireLedgerName(w, r)
if !ok {
return
}
// Decode request body into protobuf CreateTransactionPayload.
// The custom UnmarshalJSON in service.pb.json.go drives field naming
// from the public camelCase contract (scriptReference, accountMetadata,
// …) — the default protoc-gen-go tags are snake_case and would silently
// drop multi-word keys (#452).
req := &servicepb.CreateTransactionPayload{}
err := json.UnmarshalRead(r.Body, req)
Temporal Python SDK · async def execute_activity(
temporalio/workflow/_activities.py · 337–350 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
async def execute_activity(
activity: CallableAsyncNoParam[ReturnType],
*,
task_queue: str | None = None,
schedule_to_close_timeout: timedelta | None = None,
schedule_to_start_timeout: timedelta | None = None,
start_to_close_timeout: timedelta | None = None,
heartbeat_timeout: timedelta | None = None,
retry_policy: temporalio.common.RetryPolicy | None = None,
cancellation_type: ActivityCancellationType = ActivityCancellationType.TRY_CANCEL,
activity_id: str | None = None,
versioning_intent: VersioningIntent | None = None,
summary: str | None = None,
event_groups: Sequence[EventGroup] | None = None,
实现与验收要点
换模型/重试跨实例一致、计费事实及多执行者并发预留。