You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
3.4 KiB
57 lines
3.4 KiB
/* Сетевые выдачи raw ETCP с собственным NCD-владением пира; reverse/терминальные уведомления через router. |
|
* Одна управляющая FIFO и waiter на пира для всех групп/трансляций. DATA читается из кольца в момент отправки. |
|
* STREAM_RECEIVE принадлежит вызывающему даже после отмены/stop; close снимает только данную выдачу. |
|
* API выполняется в uasync-потоке. Автоматический выбор/перенос поставщиков — отдельный планировщик. */ |
|
#ifndef STREAM_NETWORK_H |
|
#define STREAM_NETWORK_H |
|
|
|
#include "stream.h" |
|
#include "stream_wire.h" |
|
#include "stream_load.h" |
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
struct stream_network; |
|
struct STREAM_RECEIVE; |
|
enum stream_receive_state { STREAM_RECEIVE_CONNECTING, STREAM_RECEIVE_INFO, STREAM_RECEIVE_REQUESTED, |
|
STREAM_RECEIVE_ACTIVE, STREAM_RECEIVE_ENDED, STREAM_RECEIVE_CLOSED }; |
|
struct stream_receive_info { |
|
uint64_t handle, peer, start, next, blocks, gaps; |
|
enum stream_receive_state state; |
|
int reason; |
|
struct stream_metric_snapshot metrics, supplier_metrics; |
|
uint32_t rtt_ms; |
|
int metrics_valid, supplier_metrics_valid, rtt_valid, close_requested; |
|
}; |
|
/* out заранее NULL; seq=UINT64_MAX: первая выдача с конца, остальные ждут её проверенный общий старт. |
|
* peer должен быть онлайн-кандидатом группы. Повтор peer+stream+sub не создаёт вторую выдачу. */ |
|
int stream_receive_open(struct STREAM_HANDLE *subscription, uint64_t peer, uint8_t subblock, uint64_t seq, struct STREAM_RECEIVE **out); |
|
void stream_receive_close(struct STREAM_RECEIVE *receive); |
|
/* Отменить текущие upstream данного локального экземпляра и начать новую попытку с конца. |
|
* Буфер/подписка/downstream сохраняются; старые receive handles становятся CLOSED и всё равно требуют close. */ |
|
int stream_receive_restart(struct STREAM_HANDLE *subscription); |
|
int stream_receive_get_info(struct STREAM_RECEIVE *receive, struct stream_receive_info *info); |
|
struct stream_peer_load_info { |
|
struct stream_load_snapshot load; |
|
uint64_t request_id, required_rate, released_rate, deadline_ms, transport_queued_bytes, inflight_bytes; |
|
uint32_t transport_queued_packets; |
|
double cpu_percent; |
|
uint64_t callback_late_ms; |
|
unsigned required_count, released_count; |
|
int global_pressure, request_active; |
|
}; |
|
int stream_peer_get_load(struct UTUN_INSTANCE *inst, uint64_t peer, struct stream_peer_load_info *info); |
|
|
|
int stream_network_init(struct UTUN_INSTANCE *inst, struct stream_network **out); |
|
void stream_network_destroy(struct stream_network *network); |
|
void stream_network_changed(struct stream_network *network); |
|
void stream_network_cancel(struct stream_network *network, const struct stream_descriptor *descriptor); |
|
void stream_network_membership_changed(struct stream_network *network, uint64_t node_id, const char *channel); |
|
void stream_network_cache_event(struct stream_network *network, const struct stream_descriptor *descriptor, |
|
const uint8_t *wire, size_t length, int added); |
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
#endif
|
|
|