Files
BitLogger/docs/api/runtime-sink-file-set-auto-flush.md
T
Nanaloveyuki 83371bb4d5 📝 补充runtime文档
2026-07-17 15:53:20 +08:00

2.4 KiB

name, group, category, update-time, description, key-word
name group category update-time description key-word
runtime-sink-file-set-auto-flush api runtime 20260707 Update the auto-flush policy used by a file-backed RuntimeSink.
runtime
sink
file
public

Runtime-sink-file-set-auto-flush

Update the auto-flush policy used by a file-backed RuntimeSink. This helper changes direct runtime durability behavior without rebuilding or rewrapping the sink.

Interface

pub fn RuntimeSink::file_set_auto_flush(self : RuntimeSink, enabled : Bool) -> Bool {

input

  • self : RuntimeSink - Runtime sink whose file auto-flush policy should change.
  • enabled : Bool - New auto-flush setting.

output

  • Bool - Whether the policy update was applied.

Explanation

Detailed rules explaining key parameters and behaviors

  • Plain File runtime variants update the wrapped FileSink auto-flush policy and return true.
  • QueuedFile runtime variants forward the update to the wrapped inner FileSink only when no queued records are pending.
  • Non-file runtime variants return false.
  • This helper changes policy only; it does not itself flush pending data.
  • If a queued file sink still has pending records, the update is rejected and returns false so already queued records are not later written under a different auto-flush policy than the one they were queued under.

How to Use

Here are some specific examples provided.

When Need Direct Runtime Durability Tuning

When a file-backed runtime sink should start flushing each write automatically:

ignore(sink.file_set_auto_flush(true))

In this example, runtime durability policy is updated without rebuilding the sink.

When Need To Relax Flush Pressure On A Runtime Sink

When file writes should stop auto-flushing for throughput reasons:

let ok = sink.file_set_auto_flush(false)

In this example, the call site updates policy explicitly and can inspect the result.

Error Case

e.g.:

  • If the runtime sink is not file-backed, the method returns false.

  • If callers need an immediate flush action, file_flush() is the operational API.

  • If a queued file sink still has pending records, callers should flush or close it first before changing auto-flush policy.

Notes

  1. Use this helper for direct runtime durability tuning on RuntimeSink values.

  2. On queued file sinks, clear pending records first so policy mutation does not retroactively affect already queued writes.