{"id":471689,"date":"2025-08-22T21:00:56","date_gmt":"2025-08-22T21:00:56","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=471689"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=471689","title":{"rendered":"<span>TitanRt \u2014 \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 (\u0438 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e HFT)<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u044f \u0437\u043d\u0430\u044e \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 Rust. \u0418\u0437 \u043a\u0443\u0441\u043a\u043e\u0432 \u043a\u043e\u0434\u0430, \u043f\u043e \u0441\u0443\u0441\u0435\u043a\u0430\u043c, \u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u043c \u043d\u0430\u0441\u043a\u0440\u0435\u0431 \u0438 \u0441\u043a\u043b\u0435\u0438\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043e\u0442\u043e\u043f\u043e\u0442\u044b \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u0443\u044e \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043b\u0438\u0431\u0443. \u0411\u0438\u0431\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043a \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u0438 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438. \u041f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0441\u0430\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u044e\u0437\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u0440\u044b \u0432 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0434\u044b \u0441 \u0437\u0430\u043a\u043e\u0441\u043e\u043c \u043f\u043e\u0434 \u0443\u043b\u044c\u0442\u0440\u0430. \u0418 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u0443 \u043f\u043e\u0434 \u0431\u0440\u0435\u043d\u0434\u043e\u043c TitanRt. \u0410 \u0435\u0441\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0437\u0430\u0439\u0434\u0435\u0442, \u0442\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f. <\/p>\n<p>\u0418\u0442\u0430\u043a, <a href=\"https:\/\/crates.io\/crates\/titanrt\" rel=\"noopener noreferrer nofollow\"><strong>TitanRt<\/strong><\/a> &#8212; typed reactive runtime \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f <strong>\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445, \u043d\u0438\u0437\u043a\u043e\u043b\u0430\u0442\u0435\u043d\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c<\/strong> \u043d\u0430 Rust.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c: \u044d\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u043e\u0441\u043d\u043e\u0432\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0436\u0438\u0432\u0443\u0442 \u0432 <strong>\u0446\u0438\u043a\u043b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/strong>, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u044b:<\/p>\n<ul>\n<li>\n<p>\u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b (\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b)<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u0430\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 (back-pressure)<\/p>\n<\/li>\n<li>\n<p>\u0447\u0451\u0442\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0435\u0451 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>\u043f\u0440\u0438\u0431\u0438\u0442\u044c \u0432\u0441\u0451 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e<\/strong>, \u0430 \u043d\u0435 \u0432\u0438\u0441\u0435\u0442\u044c \u043d\u0430 zombie-\u0442\u0440\u0435\u0434\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0417\u0430\u0447\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0440\u0430\u043d\u0442\u0430\u0439\u043c?<\/h3>\n<p>Rust \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 Tokio, Actix \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0433\u0438\u0433\u0430\u043d\u0442\u043e\u0432. \u041d\u043e \u043e\u043d\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 async\/await, HTTP-\u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<p>TitanRt \u0441\u0434\u0435\u043b\u0430\u043d \u0434\u043b\u044f <strong>\u0441\u0438\u0441\u0442\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0435 \u0434\u0432\u0438\u0436\u043a\u0438 (HFT\/market making)<\/p>\n<\/li>\n<li>\n<p>\u0430\u043d\u0430\u043b\u0438\u0437 \u0440\u044b\u043d\u043e\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u044f \u0438 \u0430\u043b\u0435\u0440\u0442\u0438\u043d\u0433<\/p>\n<\/li>\n<li>\n<p>\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 <em>\u0436\u0451\u0441\u0442\u043a\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438<\/em><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u043c, \u0433\u0434\u0435:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043b\u0438\u0448\u043d\u0438\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044f\u0434\u0440\u043e CPU, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u043d\u0443\u0436\u043d\u044b <strong>\u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u043d\u0430\u043b\u044b<\/strong> \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0438 \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h3>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0433\u0438\u0433\u0430\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 TitanRt \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043f\u0430\u0440\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438\u0434\u0435\u0439:<\/p>\n<ol>\n<li>\n<p><strong>Model-first<\/strong>:<br \/>\u0412\u0430\u0448\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 = <code>BaseModel<\/code>.<br \/>\u041e\u043d\u0430 \u0441\u0430\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u0441\u0442\u0440\u0438\u043c\u044b, \u0441\u0430\u043c\u0430 \u0438\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442, \u0445\u043e\u0442\u044f \u043d\u0435 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0437\u0432\u043d\u0435 \u0447\u0435\u0440\u0435\u0437 Control Plane \u0441\u043b\u043e\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>Connector \/ Stream layer<\/strong>:<br \/>\u041a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440 = \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0441\u0442\u0440\u0438\u043c\u043e\u0432.<br \/>\u0421\u0442\u0440\u0438\u043c = \u0432\u043e\u0440\u043a\u0435\u0440-\u0442\u0440\u0435\u0434 \u0441 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u0438 \u0432\u043a\u0443\u0441\u043d\u044f\u0442\u0438\u043d\u043e\u0439 \u0432 \u0432\u0438\u0434\u0443 StateCell&lt;T&gt;, \u0433\u0434\u0435 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c arc-swap. \u0421\u043e \u0441\u0442\u0440\u0438\u043c\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: \u0447\u0435\u0440\u0435\u0437 \u0432\u0430\u0448 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Action, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u0430\u0448 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Tx&lt;Action&gt;, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 hook, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u044b\u0440\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441\u0442\u0440\u0438\u043c\u0430, \u0432\u0430\u0448 Rx&lt;Event&gt; \u0438 StateCell&lt;T&gt; &#8212; \u0437\u0434\u0435\u0441\u044c \u0432\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438\u043c \u0446\u0438\u043a\u043b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.  <\/p>\n<\/li>\n<li>\n<p><strong>Runtime<\/strong>:<br \/>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: <code>Start<\/code>, <code>Stop<\/code>,<code>Restart<\/code>,<code>HotReload<\/code>, <code>Shutdown<\/code>. \u041d\u0443 \u0438 \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0448 \u0438\u043c\u043f\u043b execute()  \u0438\u043b\u0438 event() &#8212; \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0434\u0440\u0443\u0433 \u0433\u043e\u043d\u044f\u0435\u0442\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437\u0432\u043d\u0435 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430.<br \/> \u0412 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c, \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u0432\u0430\u0448\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f, \u043d\u043e \u043a\u0430\u043a\u0430\u044f-\u043d\u0438\u043a\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430:<\/p>\n<pre><code>                   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                    \u2502         Runtime          \u2502                    \u2502 Start\/Stop\/Restart\/...   \u2502                    \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b2\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                                \u2502                      \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                      \u2502       Model        \u2502                      \u2502 owns connectors    \u2502                      \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                                \u2502                    \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25bc\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                    \u2502     Connector(s)      \u2502                    \u2502    spawn Stream(s)    \u2502                    \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                                \u2502                     Actions \u2500\u2500\u2500\u25ba\u2502   \u2502\u25c4\u2500\u2500\u2500 Events                                \u25bc                             Stream <\/code><\/pre>\n<hr\/>\n<h3>\u041a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435<\/h3>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code class=\"rust\">use titanrt::model::{BaseModel, ExecutionResult, StopKind, StopState}; use titanrt::utils::CancelToken; use anyhow::Result;  #[derive(Clone, Debug)] struct MyConfig {     greeting: String, }  #[derive(Clone, Debug)] struct MyEvent(String);  #[derive(Clone)] struct MyOutputTx; \/\/ no-op  impl titanrt::io::base::BaseTx for MyOutputTx {     type EventType = String;     fn try_send(&amp;mut self, v: String) -&gt; Result&lt;(), titanrt::error::SendError&lt;String&gt;&gt; {         println!(\"OUT: {v}\");         Ok(())     }     fn send(         &amp;mut self,         v: String,         _: &amp;CancelToken,         _: Option&lt;std::time::Duration&gt;,     ) -&gt; Result&lt;(), titanrt::error::SendError&lt;String&gt;&gt; {         self.try_send(v)     } }  struct MyModel {     cfg: MyConfig,     out: MyOutputTx, }  impl BaseModel for MyModel {     type Config = MyConfig;     type OutputTx = MyOutputTx;     type Event = MyEvent;     type Ctx = ();      fn initialize(         _ctx: (),         config: MyConfig,         _core_id: Option&lt;usize&gt;,         output_tx: MyOutputTx,         _cancel: CancelToken,     ) -&gt; Result&lt;Self&gt; {         Ok(Self { cfg: config, out: output_tx })     }      fn execute(&amp;mut self) -&gt; ExecutionResult {         let _ = self.out.try_send(format!(\"{}!\", self.cfg.greeting));         ExecutionResult::Relax     }      fn on_event(&amp;mut self, event: MyEvent) {         let _ = self.out.try_send(format!(\"event: {}\", event.0));     }      fn stop(&amp;mut self, _kind: StopKind) -&gt; StopState {         StopState::Done     } } <\/code><\/pre>\n<p>\u0410 \u043f\u043e\u0442\u043e\u043c \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"rust\">fn main() -&gt; Result&lt;()&gt; {     let cfg = titanrt::config::RuntimeConfig {         init_model_on_start: true,         core_id: None,         max_inputs_pending: Some(1024),         max_inputs_drain: Some(64),         stop_model_timeout: Some(5),     };      let rt = titanrt::runtime::Runtime::&lt;MyModel&gt;::spawn(         cfg,         NullModelCtx,          MyConfig { greeting: \"Hello, TitanRt\".into() },         MyOutputTx,     )?;      rt.run_blocking()?;     Ok(()) } <\/code><\/pre>\n<hr\/>\n<h3>\u0427\u0435\u043c \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 Tokio?<\/h3>\n<ul>\n<li>\n<p><strong>\u0411\u0435\u0437 async\/await<\/strong>: \u0437\u0434\u0435\u0441\u044c <em>\u0447\u0435\u0441\u0442\u043d\u044b\u0435 \u0442\u0440\u0435\u0434\u044b<\/em>, \u0431\u0435\u0437 \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u043e\u043a\u0438\u043e \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>CPU pinning<\/strong>: \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0437\u0430 \u044f\u0434\u0440\u043e\u043c. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>Typed I\/O<\/strong>: \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e <code>Any<\/code>, \u0432\u0441\u0451 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0421\u0442\u0440\u043e\u0433\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0438\u043d\u0438\u043c\u0443\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/strong>: <code>crossbeam<\/code>, <code>arc-swap<\/code>,<code>ahash, ringbuf,<\/code> \u043d\u0435\u043c\u043d\u043e\u0433\u043e serde.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TitanRt<\/h3>\n<ul>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e <strong>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/strong> \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0448 \u043a\u043e\u0434 \u0436\u0438\u0432\u0451\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0442\u0430\u043a\u0430\u043d\u0430, \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438, \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b \u043f\u0438\u0448\u0435\u0442\u0435 <strong>HFT-\u0434\u0432\u0438\u0436\u043e\u043a<\/strong>, <strong>\u0440\u044b\u043d\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>, <strong>RT-\u0430\u043b\u0435\u0440\u0442\u0438\u043d\u0433<\/strong> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c <strong>\u0438\u0433\u0440\u043e\u0432\u0443\u044e \u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043f\u0435\u0442\u043b\u044e<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d HTTP, gRPC, \u0431\u0430\u0437\u0430 \u0438 \u0432\u0435\u0431 \u2014 \u0431\u0435\u0440\u0438\u0442\u0435 Tokio\/Actix, TitanRt \u043d\u0435 \u043f\u0440\u043e \u044d\u0442\u043e.<\/p>\n<hr\/>\n<h3>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/crates.io\/crates\/titanrt\" rel=\"noopener noreferrer nofollow\">Crates.io<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.rs\/titanrt\/0.1.0\/titanrt\/\" rel=\"noopener noreferrer nofollow\">Docs.rs<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/rgnatovsky\/titanrt\" rel=\"noopener noreferrer nofollow\">GitHub<\/a> \u2014 \u043a\u043e\u0434, \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>TitanRt \u2014 \u044d\u0442\u043e <strong>\u0441\u043a\u0435\u043b\u0435\u0442<\/strong> \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c.<br \/> \u0412\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u2192 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u0441\u0442\u0440\u0438\u043c\u044b \u2192 \u0441\u0442\u0440\u0438\u043c\u044b \u0433\u043e\u043d\u044f\u044e\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u2192 \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e \u0438 \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e.<\/p>\n<hr\/>\n<p>\u041f\u043b\u044e\u0448\u043a\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e yellowstone-grpc \u0441\u0442\u0440\u0438\u043c\u0430:<\/p>\n<pre><code class=\"rust\"> pub struct CompositeConnector {     pub(crate) config: CompositeConfig,     pub(crate) cancel_token: CancelToken,     pub(crate) core_stats: Option&lt;Arc&lt;CoreStats&gt;&gt;, }  impl BaseConnector for CompositeConnector {     type Config = CompositeConfig;      fn init(         config: Self::Config,         cancel_token: CancelToken,         reserved_core_ids: Option&lt;Vec&lt;usize&gt;&gt;,     ) -&gt; anyhow::Result&lt;Self&gt; {         let core_stats = if config.with_core_stats {             Some(CoreStats::new(                 config.default_max_cores,                 config.specific_cores.clone(),                 reserved_core_ids.unwrap_or_default(),             )?)         } else {             None         };          Ok(Self {             config,             cancel_token,             core_stats,         })     }      fn name(&amp;self) -&gt; impl AsRef&lt;str&gt; + Display {         \"CompositeConnector\"     }      fn config(&amp;self) -&gt; &amp;Self::Config {         &amp;self.config     }      fn cancel_token(&amp;self) -&gt; &amp;CancelToken {         &amp;self.cancel_token     }      fn cores_stats(&amp;self) -&gt; Option&lt;Arc&lt;CoreStats&gt;&gt; {         self.core_stats.clone()     } }  #[derive(Clone)] pub enum GeyserAction {    Subscribe(SubscribeRequest),       UnsubscribeAll, }  #[derive(Clone, Debug)] pub struct GeyserGrpcDescriptor {     pub endpoint: String,     pub auth_token: Option&lt;String&gt;,     pub max_pending_actions: Option&lt;usize&gt;,     pub max_pending_events: Option&lt;usize&gt;,     pub core_pick_policy: CorePickPolicy,     pub subscription: Option&lt;SubscribeRequest&gt;, }  impl GeyserGrpcDescriptor {     pub fn new(         endpoint: String,         auth_token: Option&lt;String&gt;,         max_pending_actions: Option&lt;usize&gt;,         max_pending_events: Option&lt;usize&gt;,         core_pick_policy: CorePickPolicy,     ) -&gt; Self {         Self {             endpoint,             auth_token,             max_pending_actions,             max_pending_events,             core_pick_policy,             subscription: None,         }     }      pub fn with_subscription(mut self, sub: SubscribeRequest) -&gt; Self {         self.subscription = Some(sub);         self     } }  impl StreamDescriptor for GeyserGrpcDescriptor {     fn venue(&amp;self) -&gt; impl Venue {         Venues::Solana     }      fn kind(&amp;self) -&gt; impl Kind {         \"YellowstoneGrpc\"     }      fn max_pending_actions(&amp;self) -&gt; Option&lt;usize&gt; {         self.max_pending_actions     }      fn max_pending_events(&amp;self) -&gt; Option&lt;usize&gt; {         self.max_pending_events     }      fn core_pick_policy(&amp;self) -&gt; Option&lt;CorePickPolicy&gt; {         Some(self.core_pick_policy)     }      fn health_at_start(&amp;self) -&gt; bool {         false     } }  #[derive(Clone, Debug)] pub enum GeyserEvent {     Raw(UpdateOneof), }  impl&lt;E, S&gt; StreamSpawner&lt;GeyserGrpcDescriptor, E, S&gt; for CompositeConector where     S: StateMarker,     E: BaseTx + TxPairExt, { }  impl&lt;E, S&gt; StreamRunner&lt;GeyserGrpcDescriptor, E, S&gt; for CompositeConector where     S: StateMarker,     E: BaseTx, {     type Config = ();     type ActionTx = RingSender&lt;GeyserAction&gt;;     type RawEvent = GeyserEvent;     type Hook = fn(&amp;Self::RawEvent, &amp;mut E, &amp;StateCell&lt;S&gt;);      fn build_config(&amp;mut self, _desc: &amp;GeyserGrpcDescriptor) -&gt; anyhow::Result&lt;Self::Config&gt; {         Ok(())     }      fn run(         mut ctx: RuntimeCtx&lt;GeyserGrpcDescriptor, Self, E, S&gt;,         hook: Self::Hook,     ) -&gt; StreamResult&lt;()&gt; {         \/\/ \u041e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0422\u041e\u041b\u042c\u041a\u041e \u0432\u043d\u0443\u0442\u0440\u0438 run (\u0432\u043d\u0435\u0448\u043d\u0438\u0439 API \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c)         let rt = Builder::new_current_thread()             .enable_time()             .enable_io()             .build()             .map_err(|e| StreamError::Unknown(anyhow!(e)))?;          let mut rng = SmallRng::from_os_rng();         let mut backoff_ms: u64 = 50;         let backoff_max_ms: u64 = 5_000;         let backoff_mul: f64 = 1.7;          if !ctx.desc.health_at_start() {             ctx.health.set(true);         }          rt.block_on(async move {             'reconnect: loop {                 if ctx.cancel.is_cancelled() { break Ok(()); }                  if backoff_ms &gt; 50 {                     let j = rng.random_range(0..(backoff_ms \/ 5 + 1));                     tokio::time::sleep(Duration::from_millis(j)).await;                 }                  let mut client = match GeyserGrpcClient::build_from_shared(ctx.desc.endpoint.clone())                     .map_err(|e| StreamError::Unknown(anyhow!(e)))?                     .x_token(ctx.desc.auth_token.clone())                     .map_err(|e| StreamError::Unknown(anyhow!(e)))?                     .tls_config(ClientTlsConfig::new().with_native_roots())                     .map_err(|e| StreamError::Unknown(anyhow!(e)))?                     .connect().await                 {                     Ok(c) =&gt; c,                     Err(e) =&gt; {                         tracing::warn!(\"grpc connect error: {e}\");                         let sleep = backoff_ms.min(backoff_max_ms);                         tokio::time::sleep(Duration::from_millis(sleep)).await;                         backoff_ms = ((backoff_ms as f64) * backoff_mul) as u64;                         continue 'reconnect;                     }                 };                  let (mut tx, mut rx) = match client.subscribe().await {                     Ok(x) =&gt; x,                     Err(e) =&gt; {                         tracing::warn!(\"subscribe call error: {e}\");                         let sleep = backoff_ms.min(backoff_max_ms);                         tokio::time::sleep(Duration::from_millis(sleep)).await;                         backoff_ms = ((backoff_ms as f64) * backoff_mul) as u64;                         continue 'reconnect;                     }                 };                  if let Some(req) = ctx.desc.subscription.as_ref() {                     if let Err(e) = tx.send(req.clone()).await {                         tracing::warn!(\"send initial subreq: {e}\");                     }                 }                  ctx.health.set(true);                  backoff_ms = 50;                  let mut tick = tokio::time::interval(Duration::from_millis(1));                 tick.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);                  'session: loop {                     tokio::select! {                         biased;                          m = rx.next() =&gt; {                             match m {                                 Some(Ok(update)) =&gt; {                                     match update.update_oneof {                                          Some(UpdateOneof::Ping(_)) =&gt; {                                             tracing::debug!(\"ping update\");                                             let _ = tx.send(SubscribeRequest {                                                                ping: Some(SubscribeRequestPing {id: 0}),                                                               ..Default::default()                                                              }).await;                                         }                                         Some(u) =&gt; {                                                 \/\/ \u0410 \u0432\u043e\u0442 \u0438 \u0445\u0443\u043a \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438: \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u0430\u043c\u0430 \u0440\u0435\u0448\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c                                                 hook(&amp;GeyserEvent::Raw(u), &amp;mut ctx.event_tx, &amp;ctx.state);                                         }                                         None =&gt; {}                                     }                                 }                                 Some(Err(status)) =&gt; {                                     tracing::warn!(\"grpc stream error: {status}\");                                     ctx.health.set(false);                                     break 'session;                                 }                                 None =&gt; {                                     tracing::warn!(\"grpc stream ended\");                                     ctx.health.set(false);                                     break 'session;                                 }                             }                         }                          _ = tick.tick() =&gt; {                             let mut sent = 0usize;                              \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0438                             while let Ok(a) = ctx.action_rx.try_recv() {                                 match a {                                     GeyserAction::Subscribe(req) =&gt; {                                         match tx.send(req).await {                                             Ok(_) =&gt; {                                                 sent += 1;                                                 if sent &gt;= 4096 { break; }                                             }                                             Err(e) =&gt; {                                                 tracing::warn!(\"subreq send failed: {e}\");                                                 break 'session;                                             }                                         }                                     },                                     GeyserAction::UnsubscribeAll =&gt; {}                                 }                             }                         }                     }                     if ctx.cancel.is_cancelled() { break 'reconnect Ok(()); }                 }                  let sleep = backoff_ms.min(backoff_max_ms);                 tokio::time::sleep(Duration::from_millis(sleep)).await;                 backoff_ms = ((backoff_ms as f64) * backoff_mul) as u64;             }         })?;          Ok(())     } } <\/code><\/pre>\n<p>\u041d\u0443 \u0447\u0442\u043e, \u0434\u0435\u043b\u0430\u0435\u043c SolanaTxStream \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u043b\u0438\u0434\u0435\u0440\u0430\u043c?<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><\/p>\n<div class=\"tm-article-poll-container\"><!--[--><\/p>\n<div class=\"tm-article-poll tm-article-poll_variant-bordered\">\n<div class=\"tm-notice tm-notice_positive tm-article-poll__notice\"><!----><\/p>\n<div class=\"tm-notice__inner\"><!----><\/p>\n<div class=\"tm-notice__content\" data-test-id=\"notice-content\"><!--[--><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/articles\/939966\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><!--]--><\/div>\n<\/div>\n<\/div>\n<p><!--[--><\/p>\n<div class=\"tm-article-poll__header\">\u0420\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u043c \u0442\u0435\u043c\u0443?<\/div>\n<div class=\"tm-article-poll__answers\"><!--[--><\/p>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">66.67%<\/span><span class=\"tm-article-poll__answer-label\">\u0414\u0430<\/span><span class=\"tm-article-poll__answer-votes\">2<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width: 66.67%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">33.33%<\/span><span class=\"tm-article-poll__answer-label\">\u041d\u0435\u0442<\/span><span class=\"tm-article-poll__answer-votes\">1<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 33.33%\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">0%<\/span><span class=\"tm-article-poll__answer-label\">\u0415\u0441\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0443\u0434\u0443\u0442 HFT \u043f\u043b\u044e\u0448\u043a\u0438<\/span><span class=\"tm-article-poll__answer-votes\">0<\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width: 0%\"><\/div>\n<\/div>\n<\/div>\n<p><!--]--><\/div>\n<div class=\"tm-article-poll__stats\"> \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 3 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.    \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 2 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. <\/div>\n<p><!--]--><\/div>\n<p><!--]--><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/939966\/\"> https:\/\/habr.com\/ru\/articles\/939966\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432\u043e\u0435\u0434\u0438\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u044f \u0437\u043d\u0430\u044e \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0432 \u0441\u0432\u044f\u0437\u043a\u0435 \u0441 Rust. \u0418\u0437 \u043a\u0443\u0441\u043a\u043e\u0432 \u043a\u043e\u0434\u0430, \u043f\u043e \u0441\u0443\u0441\u0435\u043a\u0430\u043c, \u0447\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u043f\u043e \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f\u043c \u043d\u0430\u0441\u043a\u0440\u0435\u0431 \u0438 \u0441\u043a\u043b\u0435\u0438\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u043e\u0442\u043e\u043f\u043e\u0442\u044b \u0434\u043e\u0441\u0442\u043e\u0439\u043d\u0443\u044e \u043a \u0432\u0430\u0448\u0435\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044e \u043b\u0438\u0431\u0443. \u0411\u0438\u0431\u043b\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0441\u0442\u0440\u0435\u043c\u0438\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438 \u043a \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438, \u0438 \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u0438. \u041f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0441\u0430\u043c \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u044e\u0437\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0441\u043e \u0441\u0442\u0430\u0440\u043e\u0439 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0439 \u0442\u043e\u0440\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0444\u0440\u044b \u0432 \u0438\u0441\u0442\u0438\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0434\u044b \u0441 \u0437\u0430\u043a\u043e\u0441\u043e\u043c \u043f\u043e\u0434 \u0443\u043b\u044c\u0442\u0440\u0430. \u0418 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u043b\u0438\u0431\u0443 \u043f\u043e\u0434 \u0431\u0440\u0435\u043d\u0434\u043e\u043c TitanRt. \u0410 \u0435\u0441\u043b\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0443 \u0437\u0430\u0439\u0434\u0435\u0442, \u0442\u0430\u043a \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u0438 \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f. <\/p>\n<p>\u0418\u0442\u0430\u043a, <a href=\"https:\/\/crates.io\/crates\/titanrt\" rel=\"noopener noreferrer nofollow\"><strong>TitanRt<\/strong><\/a> &#8212; typed reactive runtime \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f <strong>\u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445, \u043d\u0438\u0437\u043a\u043e\u043b\u0430\u0442\u0435\u043d\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c<\/strong> \u043d\u0430 Rust.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c: \u044d\u0442\u043e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u0438\u0441\u0442\u0438\u0447\u043d\u0430\u044f \u043e\u0441\u043d\u043e\u0432\u0430 \u0434\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0436\u0438\u0432\u0443\u0442 \u0432 <strong>\u0446\u0438\u043a\u043b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/strong>, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u044b:<\/p>\n<ul>\n<li>\n<p>\u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b (\u0430 \u0438\u043d\u043e\u0433\u0434\u0430 \u0438 \u043d\u0430\u043d\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u044b)<\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u0430\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 (back-pressure)<\/p>\n<\/li>\n<li>\n<p>\u0447\u0451\u0442\u043a\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0438 \u0435\u0451 \u0432\u043e\u0440\u043a\u0435\u0440\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u0438\u0431\u043a\u043e\u0441\u0442\u044c \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c <strong>\u043f\u0440\u0438\u0431\u0438\u0442\u044c \u0432\u0441\u0451 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e<\/strong>, \u0430 \u043d\u0435 \u0432\u0438\u0441\u0435\u0442\u044c \u043d\u0430 zombie-\u0442\u0440\u0435\u0434\u0430\u0445<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0417\u0430\u0447\u0435\u043c \u0435\u0449\u0451 \u043e\u0434\u0438\u043d \u0440\u0430\u043d\u0442\u0430\u0439\u043c?<\/h3>\n<p>Rust \u0443\u0436\u0435 \u0438\u043c\u0435\u0435\u0442 Tokio, Actix \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0433\u0438\u0433\u0430\u043d\u0442\u043e\u0432. \u041d\u043e \u043e\u043d\u0438 \u0440\u0435\u0448\u0430\u044e\u0442 \u0434\u0440\u0443\u0433\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u2014 \u0432\u044b\u0441\u043e\u043a\u043e\u0443\u0440\u043e\u0432\u043d\u0435\u0432\u044b\u0439 async\/await, HTTP-\u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<p>TitanRt \u0441\u0434\u0435\u043b\u0430\u043d \u0434\u043b\u044f <strong>\u0441\u0438\u0441\u0442\u0435\u043c \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/strong>:<\/p>\n<ul>\n<li>\n<p>\u0442\u043e\u0440\u0433\u043e\u0432\u044b\u0435 \u0434\u0432\u0438\u0436\u043a\u0438 (HFT\/market making)<\/p>\n<\/li>\n<li>\n<p>\u0430\u043d\u0430\u043b\u0438\u0437 \u0440\u044b\u043d\u043e\u0447\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432<\/p>\n<\/li>\n<li>\n<p>\u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u044f \u0438 \u0430\u043b\u0435\u0440\u0442\u0438\u043d\u0433<\/p>\n<\/li>\n<li>\n<p>\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0441 <em>\u0436\u0451\u0441\u0442\u043a\u0438\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0435\u043c \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438<\/em><\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0442\u0430\u043c, \u0433\u0434\u0435:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u043b\u044c\u0437\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u043b\u0438\u0448\u043d\u0438\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440<\/p>\n<\/li>\n<li>\n<p>\u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044f\u0434\u0440\u043e CPU, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0442\u043e\u043a<\/p>\n<\/li>\n<li>\n<p>\u043d\u0443\u0436\u043d\u044b <strong>\u0441\u0442\u0440\u043e\u0433\u043e \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u043d\u0430\u043b\u044b<\/strong> \u043c\u0435\u0436\u0434\u0443 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u0438 \u0432\u043e\u0440\u043a\u0435\u0440\u0430\u043c\u0438<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430<\/h3>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u0433\u0438\u0433\u0430\u043d\u0442\u0441\u043a\u043e\u0433\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 TitanRt \u2014 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043f\u0430\u0440\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0438\u0434\u0435\u0439:<\/p>\n<ol>\n<li>\n<p><strong>Model-first<\/strong>:<br \/>\u0412\u0430\u0448\u0430 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0430 = <code>BaseModel<\/code>.<br \/>\u041e\u043d\u0430 \u0441\u0430\u043c\u0430 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u0441\u0442\u0440\u0438\u043c\u044b, \u0441\u0430\u043c\u0430 \u0438\u043c\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442, \u0445\u043e\u0442\u044f \u043d\u0435 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0437\u0432\u043d\u0435 \u0447\u0435\u0440\u0435\u0437 Control Plane \u0441\u043b\u043e\u0439.<\/p>\n<\/li>\n<li>\n<p><strong>Connector \/ Stream layer<\/strong>:<br \/>\u041a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440 = \u0444\u0430\u0431\u0440\u0438\u043a\u0430 \u0441\u0442\u0440\u0438\u043c\u043e\u0432.<br \/>\u0421\u0442\u0440\u0438\u043c = \u0432\u043e\u0440\u043a\u0435\u0440-\u0442\u0440\u0435\u0434 \u0441 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438 \u0438 \u0432\u043a\u0443\u0441\u043d\u044f\u0442\u0438\u043d\u043e\u0439 \u0432 \u0432\u0438\u0434\u0443 StateCell&lt;T&gt;, \u0433\u0434\u0435 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c arc-swap. \u0421\u043e \u0441\u0442\u0440\u0438\u043c\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438: \u0447\u0435\u0440\u0435\u0437 \u0432\u0430\u0448 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Action, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u0430\u0448 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 Tx&lt;Action&gt;, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 hook, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0441\u044b\u0440\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441\u0442\u0440\u0438\u043c\u0430, \u0432\u0430\u0448 Rx&lt;Event&gt; \u0438 StateCell&lt;T&gt; &#8212; \u0437\u0434\u0435\u0441\u044c \u0432\u044b \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u0440\u043a\u0435\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438\u043c \u0446\u0438\u043a\u043b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438.  <\/p>\n<\/li>\n<li>\n<p><strong>Runtime<\/strong>:<br \/>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043f\u043e\u0442\u043e\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u043e\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: <code>Start<\/code>, <code>Stop<\/code>,<code>Restart<\/code>,<code>HotReload<\/code>, <code>Shutdown<\/code>. \u041d\u0443 \u0438 \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0430\u0448 \u0438\u043c\u043f\u043b execute()  \u0438\u043b\u0438 event() &#8212; \u0435\u0441\u043b\u0438 \u0432\u044b \u0432\u0434\u0440\u0443\u0433 \u0433\u043e\u043d\u044f\u0435\u0442\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437\u0432\u043d\u0435 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0430.<br \/> \u0412 \u043e\u0431\u0449\u0435\u043c \u0438 \u0446\u0435\u043b\u043e\u043c, \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043f\u0440\u043e \u0432\u0430\u0448\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u044b \u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c \u043c\u043e\u0434\u0435\u043b\u0438.<\/p>\n<\/li>\n<\/ol>\n<p>\u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u0434\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f, \u043d\u043e \u043a\u0430\u043a\u0430\u044f-\u043d\u0438\u043a\u0430\u043a\u0430\u044f \u0441\u0445\u0435\u043c\u0430:<\/p>\n<pre><code>                   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                    \u2502         Runtime          \u2502                    \u2502 Start\/Stop\/Restart\/...   \u2502                    \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25b2\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                                \u2502                      \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                      \u2502       Model        \u2502                      \u2502 owns connectors    \u2502                      \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                                \u2502                    \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25bc\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                    \u2502     Connector(s)      \u2502                    \u2502    spawn Stream(s)    \u2502                    \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518                                \u2502                     Actions \u2500\u2500\u2500\u25ba\u2502   \u2502\u25c4\u2500\u2500\u2500 Events                                \u25bc                             Stream <\/code><\/pre>\n<hr\/>\n<h3>\u041a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435<\/h3>\n<p>\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c:<\/p>\n<pre><code class=\"rust\">use titanrt::model::{BaseModel, ExecutionResult, StopKind, StopState}; use titanrt::utils::CancelToken; use anyhow::Result;  #[derive(Clone, Debug)] struct MyConfig {     greeting: String, }  #[derive(Clone, Debug)] struct MyEvent(String);  #[derive(Clone)] struct MyOutputTx; \/\/ no-op  impl titanrt::io::base::BaseTx for MyOutputTx {     type EventType = String;     fn try_send(&amp;mut self, v: String) -&gt; Result&lt;(), titanrt::error::SendError&lt;String&gt;&gt; {         println!(\"OUT: {v}\");         Ok(())     }     fn send(         &amp;mut self,         v: String,         _: &amp;CancelToken,         _: Option&lt;std::time::Duration&gt;,     ) -&gt; Result&lt;(), titanrt::error::SendError&lt;String&gt;&gt; {         self.try_send(v)     } }  struct MyModel {     cfg: MyConfig,     out: MyOutputTx, }  impl BaseModel for MyModel {     type Config = MyConfig;     type OutputTx = MyOutputTx;     type Event = MyEvent;     type Ctx = ();      fn initialize(         _ctx: (),         config: MyConfig,         _core_id: Option&lt;usize&gt;,         output_tx: MyOutputTx,         _cancel: CancelToken,     ) -&gt; Result&lt;Self&gt; {         Ok(Self { cfg: config, out: output_tx })     }      fn execute(&amp;mut self) -&gt; ExecutionResult {         let _ = self.out.try_send(format!(\"{}!\", self.cfg.greeting));         ExecutionResult::Relax     }      fn on_event(&amp;mut self, event: MyEvent) {         let _ = self.out.try_send(format!(\"event: {}\", event.0));     }      fn stop(&amp;mut self, _kind: StopKind) -&gt; StopState {         StopState::Done     } } <\/code><\/pre>\n<p>\u0410 \u043f\u043e\u0442\u043e\u043c \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code class=\"rust\">fn main() -&gt; Result&lt;()&gt; {     let cfg = titanrt::config::RuntimeConfig {         init_model_on_start: true,         core_id: None,         max_inputs_pending: Some(1024),         max_inputs_drain: Some(64),         stop_model_timeout: Some(5),     };      let rt = titanrt::runtime::Runtime::&lt;MyModel&gt;::spawn(         cfg,         NullModelCtx,          MyConfig { greeting: \"Hello, TitanRt\".into() },         MyOutputTx,     )?;      rt.run_blocking()?;     Ok(()) } <\/code><\/pre>\n<hr\/>\n<h3>\u0427\u0435\u043c \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442 Tokio?<\/h3>\n<ul>\n<li>\n<p><strong>\u0411\u0435\u0437 async\/await<\/strong>: \u0437\u0434\u0435\u0441\u044c <em>\u0447\u0435\u0441\u0442\u043d\u044b\u0435 \u0442\u0440\u0435\u0434\u044b<\/em>, \u0431\u0435\u0437 \u0441\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u043e\u043a\u0438\u043e \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438.<\/p>\n<\/li>\n<li>\n<p><strong>CPU pinning<\/strong>: \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a \u0437\u0430 \u044f\u0434\u0440\u043e\u043c. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0432 \u0431\u0443\u0434\u0443\u0449\u0438\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430 \u0438 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u043d\u043e\u0441\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p><strong>Typed I\/O<\/strong>: \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e <code>Any<\/code>, \u0432\u0441\u0451 \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u0421\u0442\u0440\u043e\u0433\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>\u041c\u0438\u043d\u0438\u043c\u0443\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/strong>: <code>crossbeam<\/code>, <code>arc-swap<\/code>,<code>ahash, ringbuf,<\/code> \u043d\u0435\u043c\u043d\u043e\u0433\u043e serde.<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c TitanRt<\/h3>\n<ul>\n<li>\n<p>\u041d\u0443\u0436\u043d\u043e <strong>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/strong> \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0430\u0448 \u043a\u043e\u0434 \u0436\u0438\u0432\u0451\u0442 \u0432 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435: \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0441\u0442\u0430\u043a\u0430\u043d\u0430, \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438, \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0412\u044b \u043f\u0438\u0448\u0435\u0442\u0435 <strong>HFT-\u0434\u0432\u0438\u0436\u043e\u043a<\/strong>, <strong>\u0440\u044b\u043d\u043e\u043a \u0434\u0430\u043d\u043d\u044b\u0445<\/strong>, <strong>RT-\u0430\u043b\u0435\u0440\u0442\u0438\u043d\u0433<\/strong> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c <strong>\u0438\u0433\u0440\u043e\u0432\u0443\u044e \u0441\u0435\u0442\u0435\u0432\u0443\u044e \u043f\u0435\u0442\u043b\u044e<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u0435\u043d HTTP, gRPC, \u0431\u0430\u0437\u0430 \u0438 \u0432\u0435\u0431 \u2014 \u0431\u0435\u0440\u0438\u0442\u0435 Tokio\/Actix, TitanRt \u043d\u0435 \u043f\u0440\u043e \u044d\u0442\u043e.<\/p>\n<hr\/>\n<h3>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/crates.io\/crates\/titanrt\" rel=\"noopener noreferrer nofollow\">Crates.io<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/docs.rs\/titanrt\/0.1.0\/titanrt\/\" rel=\"noopener noreferrer nofollow\">Docs.rs<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/rgnatovsky\/titanrt\" rel=\"noopener noreferrer nofollow\">GitHub<\/a> \u2014 \u043a\u043e\u0434, \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>TitanRt \u2014 \u044d\u0442\u043e <strong>\u0441\u043a\u0435\u043b\u0435\u0442<\/strong> \u0434\u043b\u044f \u0440\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c, \u0433\u0434\u0435 \u0432\u0430\u0436\u043d\u0430 \u043b\u0430\u0442\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c.<br \/> \u0412\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u044c \u0438 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u2192 \u043c\u043e\u0434\u0435\u043b\u044c \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u0441\u0442\u0440\u0438\u043c\u044b \u2192 \u0441\u0442\u0440\u0438\u043c\u044b \u0433\u043e\u043d\u044f\u044e\u0442 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u2192 \u0440\u0430\u043d\u0442\u0430\u0439\u043c \u0441\u043b\u0435\u0434\u0438\u0442 \u0437\u0430 \u0436\u0438\u0437\u043d\u0435\u043d\u043d\u044b\u043c \u0446\u0438\u043a\u043b\u043e\u043c.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e, \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e \u0438 \u0442\u0438\u043f\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e.<\/p>\n<hr\/>\n<p>\u041f\u043b\u044e\u0448\u043a\u0430 \u0432 \u0432\u0438\u0434\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e yellowstone-grpc \u0441\u0442\u0440\u0438\u043c\u0430:<\/p>\n<pre><code class=\"rust\"> pub struct CompositeConnector {     pub(crate) config: CompositeConfig,     pub(crate) cancel_token: CancelToken,     pub(crate) core_stats: Option&lt;Arc&lt;CoreStats&gt;&gt;, }  impl BaseConnector for CompositeConnector {     type Config = CompositeConfig;      fn init(         config: Self::Config,         cancel_token: CancelToken,         reserved_core_ids: Option&lt;Vec&lt;usize&gt;&gt;,     ) -&gt; anyhow::Result&lt;Self&gt; {         let core_stats = if config.with_core_stats {             Some(CoreStats::new(                 config.default_max_cores,                 config.specific_cores.clone(),                 reserved_core_ids.unwrap_or_default(),             )?)         } else {             None         };          Ok(Self {             config,             cancel_token,             core_stats,         })     }      fn name(&amp;self) -&gt; impl AsRef&lt;str&gt; + Display {         \"CompositeConnector\"     }      fn config(&amp;self) -&gt; &amp;Self::Config {         &amp;self.config     }      fn cancel_token(&amp;self) -&gt; &amp;CancelToken {         &amp;self.cancel_token     }      fn cores_stats(&amp;self) -&gt; Option&lt;Arc&lt;CoreStats&gt;&gt; {         self.core_stats.clone()     } }  #[derive(Clone)] pub enum GeyserAction {    Subscribe(SubscribeRequest),       UnsubscribeAll, }  #[derive(Clone, Debug)] pub struct GeyserGrpcDescriptor {     pub endpoint: String,     pub auth_token: Option&lt;String&gt;,     pub max_pending_actions: Option&lt;usize&gt;,     pub max_pending_events: Option&lt;usize&gt;,     pub core_pick_policy: CorePickPolicy,     pub subscription: Option&lt;SubscribeRequest&gt;, }  impl GeyserGrpcDescriptor {     pub fn new(         endpoint: String,         auth_token: Option&lt;String&gt;,         max_pending_actions: Option&lt;usize&gt;,         max_pending_events: Option&lt;usize&gt;,         core_pick_policy: CorePickPolicy,     ) -&gt; Self {         Self {             endpoint,             auth_token,             max_pending_actions,             max_pending_events,             core_pick_policy,             subscription: None,         }     }      pub fn with_subscription(mut self, sub: SubscribeRequest) -&gt; Self {         self.subscription = Some(sub);         self     } }  impl StreamDescriptor for GeyserGrpcDescriptor {     fn venue(&amp;self) -&gt; impl Venue {         Venues::Solana     }      fn kind(&amp;self) -&gt; impl Kind {         \"YellowstoneGrpc\"     }      fn max_pending_actions(&amp;self) -&gt; Option&lt;usize&gt; {         self.max_pending_actions     }      fn max_pending_events(&amp;self) -&gt; Option&lt;usize&gt; {         self.max_pending_events     }      fn core_pick_policy(&amp;self) -&gt; Option&lt;CorePickPolicy&gt; {         Some(self.core_pick_policy)     }      fn health_at_start(&amp;self) -&gt; bool {         false     } }  #[derive(Clone, Debug)] pub enum GeyserEvent {     Raw(UpdateOneof), }  impl&lt;E, S&gt; StreamSpawner&lt;GeyserGrpcDescriptor, E, S&gt; for CompositeConector where     S: StateMarker,     E: BaseTx + TxPairExt, { }  impl&lt;E, S&gt; StreamRunner&lt;GeyserGrpcDescriptor, E, S&gt; for CompositeConector where     S: StateMarker,     E: BaseTx, {     type Config = ();     type ActionTx = RingSender&lt;GeyserAction&gt;;     type RawEvent = GeyserEvent;     type Hook = fn(&amp;Self::RawEvent, &amp;mut E, &amp;StateCell&lt;S&gt;);      fn build_config(&amp;mut self, _desc: &amp;GeyserGrpcDescriptor) -&gt; anyhow::Result&lt;Self::Config&gt; {         Ok(())     }      fn run(         mut ctx: RuntimeCtx&lt;GeyserGrpcDescriptor, Self, E, S&gt;,         hook: Self::Hook,     ) -&gt; StreamResult&lt;()&gt; {         \/\/ \u041e\u0434\u043d\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u044b\u0439 \u0440\u0430\u043d\u0442\u0430\u0439\u043c<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-471689","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471689","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=471689"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471689\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471689"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471689"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471689"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}