mirror of
https://github.com/Nanaloveyuki/BitLogger.git
synced 2026-07-24 00:42:18 +00:00
📝 document file sink policy mutators
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
---
|
||||
name: file-sink-clear-rotation
|
||||
group: api
|
||||
category: sink
|
||||
update-time: 20260613
|
||||
description: Disable runtime rotation on a FileSink.
|
||||
key-word:
|
||||
- file
|
||||
- sink
|
||||
- rotation
|
||||
- public
|
||||
---
|
||||
|
||||
## File-sink-clear-rotation
|
||||
|
||||
Disable runtime rotation on a `FileSink`. This helper is the direct shortcut for clearing rotation policy on the concrete sink.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn FileSink::clear_rotation(self : FileSink) -> Unit {
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : FileSink` - File sink whose rotation policy should be cleared.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- This method removes the current rotation policy by setting it to `None`.
|
||||
- It changes stored policy only and does not reopen the file.
|
||||
- Current append and auto-flush settings are left unchanged.
|
||||
- This helper is equivalent in intent to a broader setter with `None`, but is clearer at the call site.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need To Disable Rotation Explicitly
|
||||
|
||||
When direct runtime file rotation should be turned off:
|
||||
```moonbit
|
||||
sink.clear_rotation()
|
||||
```
|
||||
|
||||
In this example, rotation policy is removed directly from the sink.
|
||||
|
||||
#### When Need A Clear Intent Shortcut
|
||||
|
||||
When code should make the disable-rotation intent obvious:
|
||||
```moonbit
|
||||
sink.clear_rotation()
|
||||
ignore(sink.rotation_enabled())
|
||||
```
|
||||
|
||||
In this example, the call site reads more clearly than using a broader policy setter.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If callers need to switch to another rotation config rather than disable rotation, `set_rotation(...)` is the better API.
|
||||
|
||||
- This helper does not report past rotation failures; use `rotation_failures()` or `state()` for diagnostics.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper when the desired effect is simply “rotation off”.
|
||||
|
||||
2. It is clearer than passing `None` through a broader setter when intent matters.
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
name: file-sink-set-append-mode
|
||||
group: api
|
||||
category: sink
|
||||
update-time: 20260613
|
||||
description: Update the append-mode policy used by a FileSink for later reopen behavior.
|
||||
key-word:
|
||||
- file
|
||||
- sink
|
||||
- append
|
||||
- public
|
||||
---
|
||||
|
||||
## File-sink-set-append-mode
|
||||
|
||||
Update the append-mode policy used by a `FileSink`. This helper changes future reopen behavior on the concrete sink without forcing an immediate reopen.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn FileSink::set_append_mode(self : FileSink, append : Bool) -> Unit {
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : FileSink` - File sink whose append-mode policy should change.
|
||||
- `append : Bool` - New append-mode policy.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- This method updates stored policy only.
|
||||
- It does not force an immediate reopen.
|
||||
- The new value affects later reopen behavior.
|
||||
- The sink path and current rotation policy are left unchanged.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need To Change Future Reopen Behavior
|
||||
|
||||
When direct recovery code should later prefer append mode explicitly:
|
||||
```moonbit
|
||||
sink.set_append_mode(true)
|
||||
```
|
||||
|
||||
In this example, later reopen operations use the updated append policy.
|
||||
|
||||
#### When Want To Separate Policy Mutation From Reopen Timing
|
||||
|
||||
When code should update policy now and reopen later:
|
||||
```moonbit
|
||||
sink.set_append_mode(false)
|
||||
ignore(sink.reopen_with_current_policy())
|
||||
```
|
||||
|
||||
In this example, policy mutation and reopen timing remain separate decisions.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If callers need an immediate reopen as part of the same operation, one of the reopen helpers should be used afterward.
|
||||
|
||||
- This method does not itself prove that the sink is currently available or writable.
|
||||
|
||||
### Notes
|
||||
|
||||
1. This helper changes stored policy, not live file-handle state by itself.
|
||||
|
||||
2. It is useful when direct file-sink recovery logic wants to stage reopen behavior in advance.
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
name: file-sink-set-auto-flush
|
||||
group: api
|
||||
category: sink
|
||||
update-time: 20260613
|
||||
description: Update the auto-flush policy used by a FileSink.
|
||||
key-word:
|
||||
- file
|
||||
- sink
|
||||
- flush
|
||||
- public
|
||||
---
|
||||
|
||||
## File-sink-set-auto-flush
|
||||
|
||||
Update the auto-flush policy used by a `FileSink`. This helper changes direct runtime durability behavior without rebuilding the sink.
|
||||
|
||||
### Interface
|
||||
|
||||
```moonbit
|
||||
pub fn FileSink::set_auto_flush(self : FileSink, enabled : Bool) -> Unit {
|
||||
```
|
||||
|
||||
#### input
|
||||
|
||||
- `self : FileSink` - File sink whose auto-flush policy should change.
|
||||
- `enabled : Bool` - New auto-flush setting.
|
||||
|
||||
### Explanation
|
||||
|
||||
Detailed rules explaining key parameters and behaviors
|
||||
|
||||
- This method updates runtime policy only.
|
||||
- It does not itself flush pending data.
|
||||
- The new value affects whether later writes attempt a flush after each rendered record.
|
||||
- Existing path, append policy, and rotation policy are left unchanged.
|
||||
|
||||
### How to Use
|
||||
|
||||
Here are some specific examples provided.
|
||||
|
||||
#### When Need Direct Durability Tuning
|
||||
|
||||
When a concrete file sink should start flushing each write automatically:
|
||||
```moonbit
|
||||
sink.set_auto_flush(true)
|
||||
```
|
||||
|
||||
In this example, runtime policy is updated without rebuilding the sink.
|
||||
|
||||
#### When Need To Relax Flush Pressure
|
||||
|
||||
When a file sink should stop auto-flushing for throughput reasons:
|
||||
```moonbit
|
||||
sink.set_auto_flush(false)
|
||||
```
|
||||
|
||||
In this example, the call site updates policy explicitly on the direct file sink.
|
||||
|
||||
### Error Case
|
||||
|
||||
e.g.:
|
||||
- If callers need an immediate flush action, `flush()` is the operational API.
|
||||
|
||||
- This helper does not report whether previous writes or flushes succeeded.
|
||||
|
||||
### Notes
|
||||
|
||||
1. Use this helper for direct runtime durability tuning.
|
||||
|
||||
2. Pair it with `auto_flush_enabled()` to verify the active policy.
|
||||
@@ -146,6 +146,9 @@ BitLogger API navigation.
|
||||
- [file-sink-path.md](./file-sink-path.md)
|
||||
- [file-sink-auto-flush-enabled.md](./file-sink-auto-flush-enabled.md)
|
||||
- [file-sink-rotation-enabled.md](./file-sink-rotation-enabled.md)
|
||||
- [file-sink-set-append-mode.md](./file-sink-set-append-mode.md)
|
||||
- [file-sink-set-auto-flush.md](./file-sink-set-auto-flush.md)
|
||||
- [file-sink-clear-rotation.md](./file-sink-clear-rotation.md)
|
||||
- [file-sink-type.md](./file-sink-type.md)
|
||||
- [native-files-supported.md](./native-files-supported.md)
|
||||
- [file-rotation.md](./file-rotation.md)
|
||||
|
||||
Reference in New Issue
Block a user