Class: Snails::Logger::Delivery
- Defined in:
- runtime/snails/logger/delivery.rbs,
runtime/snails/logger/delivery.rb
Defined Under Namespace
Classes: DroppedBatch, RetainedBatch
Constant Summary collapse
- MAX_RECORDS =
The batch size that hands off without waiting for the clock.
100- FLUSH_INTERVAL_SECONDS =
How often the scheduler flushes the buffer, in seconds.
1
Instance Method Summary collapse
-
#after_fork ⇒ void
make this process's buffer its own: records buffered by the parent would otherwise be sent by every child, and the inherited lock may be held by a thread that does not exist here.
-
#deliver(record) ⇒ Exception?
append one record to the buffer and hand the batch off when it is full.
-
#flush ⇒ Exception?
hand the current buffer over now, even when it is not full.
-
#initialize ⇒ Delivery
constructor
A new instance of Delivery.
-
#register_flush ⇒ void
put the periodic flush beat on this process's scheduler.
-
#transport ⇒ untyped
the object that receives structured records.
-
#transport=(value) ⇒ untyped
replace the record destination.
Constructor Details
#initialize ⇒ Delivery
Returns a new instance of Delivery.
29 |
# File 'runtime/snails/logger/delivery.rbs', line 29
def initialize: () -> void
|
Instance Method Details
#after_fork ⇒ void
make this process's buffer its own: records buffered by the parent would otherwise be sent by every child, and the inherited lock may be held by a thread that does not exist here. The prefork servers call it as the child's first statement, before the first record.
112 |
# File 'runtime/snails/logger/delivery.rb', line 112
def after_fork: () -> void
|
#deliver(record) ⇒ Exception?
append one record to the buffer and hand the batch off when it is full.
A non-fatal transport failure is returned for the logger to report locally. A busy database keeps the batch for the next flush (a warning, not a loss); any other failure drops it. This object does not write the local line and does not retry a real failure. Control and fatal exceptions still propagate, matching the runtime's error boundary.
147 |
# File 'runtime/snails/logger/delivery.rb', line 147
def deliver: (Record record) -> Exception?
|
#flush ⇒ Exception?
hand the current buffer over now, even when it is not full. The
scheduler calls it every FLUSH_INTERVAL_SECONDS; a shutting-down
process may call it once more. With no transport the buffer is dropped:
the local lines already exist, and keeping the records would send them
to a transport configured later.
172 |
# File 'runtime/snails/logger/delivery.rb', line 172
def flush: () -> Exception?
|
#register_flush ⇒ void
put the periodic flush beat on this process's scheduler.
ActiveJob::Launcher.start calls it once, before it spawns the loops,
so the registry is never written while the scheduler iterates it. The
flag makes a second call a no-op: a forked child inherits the beat and
the flag together, or neither.
129 |
# File 'runtime/snails/logger/delivery.rb', line 129
def register_flush: () -> void
|
#transport ⇒ untyped
the object that receives structured records.
86 |
# File 'runtime/snails/logger/delivery.rb', line 86
def transport: () -> untyped
|
#transport=(value) ⇒ untyped
replace the record destination. The contract is deliver(records) with
an Array of Record; nil disables remote delivery. The buffer belongs
to the process, not the transport, so a swap does not discard records
already waiting.
98 |
# File 'runtime/snails/logger/delivery.rb', line 98
def transport=: (untyped value) -> untyped
|