package octez-shell-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/octez-shell-libs.p2p/Tezos_p2p/P2p_io_scheduler/index.html
Module Tezos_p2p.P2p_io_scheduler
Source
Scheduling of I/O operations over file descriptors.
This module defines the scheduler type t
, and connection type connection
. A connection
is a wrapper over a P2p_fd.t
. R/W functions over connection
s behave like regular R/W over file descriptors, but the scheduler ensures of fair allocation of bandwidth between them.
To each connection is associated a read (resp. write) queue where data is copied to (resp. read from), at a rate of max_download_speed / num_connections
(resp. max_upload_speed / num_connections
).
Type of a connection.
Type of an IO scheduler.
val create :
?max_upload_speed:int ->
?max_download_speed:int ->
?read_queue_size:int ->
?write_queue_size:int ->
read_buffer_size:int ->
unit ->
t
create ~max_upload_speed ~max_download_speed ~read_queue_size ~write_queue_size ()
is an IO scheduler with specified (global) max upload (resp. download) speed, and specified read (resp. write) queue sizes (in bytes) for connections.
ma_state sched
returns the state of the moving average worker.
register sched fd
is a connection
managed by sched
.
val write :
?canceler:Lwt_canceler.t ->
connection ->
Tezos_base.TzPervasives.Bytes.t ->
unit Tezos_base.TzPervasives.tzresult Lwt.t
write conn msg
returns Ok ()
when msg
has been added to conn
's write queue, or fail with an error.
write_now conn msg
is true
iff msg
has been (immediately) added to conn
's write queue, false
if it has been dropped.
set_peer_id ~peer_id conn
sets the peer id where conn
is connected to.
Returns the readable
of an abstract connection
stat conn
is a snapshot of current bandwidth usage for conn
.
global_stat sched
is a snapshot of sched
's bandwidth usage (sum of stat conn
for each conn
in sched
).
iter_connection sched f
applies f
on each connection managed by sched
.
Stores a reason for which it will be closed in a near future.
val close :
?timeout:float ->
?reason:P2p_disconnection_reason.t ->
connection ->
unit Tezos_base.TzPervasives.tzresult Lwt.t
close ?reason conn
set the closing reason and returns after any pending data has been sent and the canceler of conn
has been triggered.
It does not wait for the canceler callbacks, so there is no guarantee that the file descriptor is already closed, but it will eventually be closed.
If timeout is set, the canceler will be triggered after the timeout, even if pending data remains to be sent.
shutdown sched
returns after all connections managed by sched
have been closed and sched
's inner worker has successfully canceled.
id connection
returns the identifier of the underlying P2p_fd.t
file descriptor. This uniquely identifies a connection.