diff --git a/Cargo.lock b/Cargo.lock index 0903614..56d2062 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,244 +3,58 @@ version = 3 [[package]] -name = "actix-codec" -version = "0.5.0" +name = "aho-corasick" +version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a7559404a7f3573127aab53c08ce37a6c6a315c374a31070f3c91cd1b4a7fe" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" dependencies = [ - "bitflags", - "bytes", - "futures-core", - "futures-sink", - "log", "memchr", - "pin-project-lite", - "tokio", - "tokio-util", ] [[package]] -name = "actix-http" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0070905b2c4a98d184c4e81025253cb192aa8a73827553f38e9410801ceb35bb" -dependencies = [ - "actix-codec", - "actix-rt", - "actix-service", - "actix-utils", - "ahash", - "base64", - "bitflags", - "brotli", - "bytes", - "bytestring", - "derive_more", - "encoding_rs", - "flate2", - "futures-core", - "h2", - "http", - "httparse", - "httpdate", - "itoa", - "language-tags", - "local-channel", - "mime", - "percent-encoding", - "pin-project-lite", - "rand", - "sha1", - "smallvec", - "tokio", - "tokio-util", - "tracing", - "zstd", -] - -[[package]] -name = "actix-macros" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a6172cf69b960917811022d8f29bc0b7fa1398bc4f78b3c466673db1213b6" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "actix-protobuf" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2e1151cdf1d5f30115da7c8e3e4cefadfb6d396973d75354647c4e8fae3a14f" -dependencies = [ - "actix-web", - "derive_more", - "futures-util", - "prost", -] - -[[package]] -name = "actix-router" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66ff4d247d2b160861fa2866457e85706833527840e4133f8f49aa423a38799" -dependencies = [ - "bytestring", - "http", - "regex", - "serde", - "tracing", -] - -[[package]] -name = "actix-rt" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15265b6b8e2347670eb363c47fc8c75208b4a4994b27192f345fcbe707804f3e" -dependencies = [ - "futures-core", - "tokio", -] - -[[package]] -name = "actix-server" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e8613a75dd50cc45f473cee3c34d59ed677c0f7b44480ce3b8247d7dc519327" -dependencies = [ - "actix-rt", - "actix-service", - "actix-utils", - "futures-core", - "futures-util", - "mio", - "num_cpus", - "socket2", - "tokio", - "tracing", -] - -[[package]] -name = "actix-service" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b894941f818cfdc7ccc4b9e60fa7e53b5042a2e8567270f9147d5591893373a" -dependencies = [ - "futures-core", - "paste", - "pin-project-lite", -] - -[[package]] -name = "actix-utils" -version = "3.0.1" +name = "anyhow" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a1dcdff1466e3c2488e1cb5c36a71822750ad43839937f85d2f4d9f8b705d8" -dependencies = [ - "local-waker", - "pin-project-lite", -] +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] -name = "actix-web" -version = "4.3.0" +name = "async-stream" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "464e0fddc668ede5f26ec1f9557a8d44eda948732f40c6b0ad79126930eb775f" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" dependencies = [ - "actix-codec", - "actix-http", - "actix-macros", - "actix-router", - "actix-rt", - "actix-server", - "actix-service", - "actix-utils", - "actix-web-codegen", - "ahash", - "bytes", - "bytestring", - "cfg-if", - "cookie", - "derive_more", - "encoding_rs", + "async-stream-impl", "futures-core", - "futures-util", - "http", - "itoa", - "language-tags", - "log", - "mime", - "once_cell", "pin-project-lite", - "regex", - "serde", - "serde_json", - "serde_urlencoded", - "smallvec", - "socket2", - "time", - "url", ] [[package]] -name = "actix-web-codegen" -version = "4.1.0" +name = "async-stream-impl" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fa9362663c8643d67b2d5eafba49e4cb2c8a053a29ed00a0bea121f17c76b13" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "actix-router", "proc-macro2", "quote", - "syn", + "syn 2.0.33", ] [[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ahash" -version = "0.7.6" +name = "async-trait" +version = "0.1.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "alloc-no-stdlib" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" - -[[package]] -name = "alloc-stdlib" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" -dependencies = [ - "alloc-no-stdlib", + "proc-macro2", + "quote", + "syn 2.0.33", ] [[package]] -name = "anyhow" -version = "1.0.69" +name = "atomic" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" +checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba" [[package]] name = "autocfg" @@ -249,10 +63,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "base64" -version = "0.21.0" +name = "binascii" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72" [[package]] name = "bitflags" @@ -261,34 +75,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] -name = "block-buffer" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" -dependencies = [ - "generic-array", -] - -[[package]] -name = "brotli" -version = "3.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a0b1dbcc8ae29329621f8d4f0d835787c1c38bb1401979b49d13b0b305ff68" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", - "brotli-decompressor", -] - -[[package]] -name = "brotli-decompressor" -version = "2.3.4" +name = "bitflags" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b6561fd3f895a11e8f72af2cb7d22e08366bebc2b6b57f7744c4bda27034744" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" [[package]] name = "bytes" @@ -296,23 +86,11 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" -[[package]] -name = "bytestring" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7f83e57d9154148e355404702e2694463241880b939570d7c97c014da7a69a1" -dependencies = [ - "bytes", -] - [[package]] name = "cc" version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" -dependencies = [ - "jobserver", -] [[package]] name = "cfg-if" @@ -320,17 +98,11 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - [[package]] name = "cookie" -version = "0.16.2" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e859cd57d0710d9e06c381b550c06e76992472a8c6d527aecd2fc673dcc231fb" +checksum = "7efb37c3e1ccb1ff97164ad95ac1606e8ccd35b3fa0a7d99a304c7f4a428cc24" dependencies = [ "percent-encoding", "time", @@ -338,54 +110,36 @@ dependencies = [ ] [[package]] -name = "cpufeatures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" -dependencies = [ - "libc", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" +name = "devise" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "d6eacefd3f541c66fc61433d65e54e0e46e0a029a819a7dbbc7a7b489e8a85f8" dependencies = [ - "cfg-if", + "devise_codegen", + "devise_core", ] [[package]] -name = "crypto-common" -version = "0.1.6" +name = "devise_codegen" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +checksum = "9c8cf4b8dd484ede80fd5c547592c46c3745a617c8af278e2b72bea86b2dfed6" dependencies = [ - "generic-array", - "typenum", + "devise_core", + "quote", ] [[package]] -name = "derive_more" -version = "0.99.17" +name = "devise_core" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +checksum = "35b50dba0afdca80b187392b24f2499a88c336d5a8493e4b4ccfb608708be56a" dependencies = [ - "convert_case", + "bitflags 2.4.0", "proc-macro2", + "proc-macro2-diagnostics", "quote", - "rustc_version", - "syn", -] - -[[package]] -name = "digest" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" -dependencies = [ - "block-buffer", - "crypto-common", + "syn 2.0.33", ] [[package]] @@ -416,6 +170,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.2.8" @@ -447,20 +207,24 @@ dependencies = [ ] [[package]] -name = "fixedbitset" -version = "0.4.2" +name = "figment" +version = "0.10.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +checksum = "4547e226f4c9ab860571e070a9034192b3175580ecea38da34fcdb53a018c9a5" +dependencies = [ + "atomic", + "pear", + "serde", + "toml", + "uncased", + "version_check", +] [[package]] -name = "flate2" -version = "1.0.25" +name = "fixedbitset" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" -dependencies = [ - "crc32fast", - "miniz_oxide", -] +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "fnv" @@ -469,52 +233,81 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] -name = "form_urlencoded" -version = "1.1.0" +name = "futures" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ - "percent-encoding", + "futures-channel", + "futures-core", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", + "futures-sink", ] [[package]] name = "futures-core" -version = "0.3.26" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-io" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-sink" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f310820bb3e8cfd46c80db4d7fb8353e15dfff853a127158425f31e0be6c8364" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-util" -version = "0.3.26" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "slab", ] [[package]] -name = "generic-array" -version = "0.14.6" +name = "generator" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e" dependencies = [ - "typenum", - "version_check", + "cc", + "libc", + "log", + "rustversion", + "windows", ] [[package]] @@ -528,11 +321,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" -version = "0.3.15" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -540,7 +339,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.2", "slab", "tokio", "tokio-util", @@ -553,6 +352,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + [[package]] name = "heck" version = "0.4.1" @@ -585,6 +390,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + [[package]] name = "httparse" version = "1.8.0" @@ -604,13 +420,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] -name = "idna" -version = "0.3.0" +name = "hyper" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", ] [[package]] @@ -620,9 +450,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", + "serde", ] +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[package]] +name = "inlinable_string" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb" + [[package]] name = "instant" version = "0.1.12" @@ -669,21 +516,6 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" -[[package]] -name = "jobserver" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" -dependencies = [ - "libc", -] - -[[package]] -name = "language-tags" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" - [[package]] name = "lazy_static" version = "1.4.0" @@ -702,24 +534,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" -[[package]] -name = "local-channel" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f303ec0e94c6c54447f84f3b0ef7af769858a9c4ef56ef2a986d3dcd4c3fc9c" -dependencies = [ - "futures-core", - "futures-sink", - "futures-util", - "local-waker", -] - -[[package]] -name = "local-waker" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34f76eb3611940e0e7d53a9aaa4e6a3151f69541a282fd0dad5571420c53ff1" - [[package]] name = "lock_api" version = "0.4.9" @@ -739,6 +553,30 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "loom" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "serde", + "serde_json", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + [[package]] name = "memchr" version = "2.5.0" @@ -751,15 +589,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "mio" version = "0.8.5" @@ -772,12 +601,42 @@ dependencies = [ "windows-sys 0.42.0", ] +[[package]] +name = "multer" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01acbdc23469fd8fe07ab135923371d5f5a422fbf9c522158677c8eb15bc51c2" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "log", + "memchr", + "mime", + "spin", + "tokio", + "tokio-util", + "version_check", +] + [[package]] name = "multimap" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + [[package]] name = "num_cpus" version = "1.15.0" @@ -794,6 +653,12 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + [[package]] name = "parking_lot" version = "0.12.1" @@ -818,10 +683,27 @@ dependencies = [ ] [[package]] -name = "paste" -version = "1.0.11" +name = "pear" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +checksum = "61a386cd715229d399604b50d1361683fe687066f42d56f54be995bc6868f71c" +dependencies = [ + "inlinable_string", + "pear_codegen", + "yansi 1.0.0-rc.1", +] + +[[package]] +name = "pear_codegen" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9f0f13dac8069c139e8300a6510e3f4143ecf5259c60b116a9b271b4ca0d54" +dependencies = [ + "proc-macro2", + "proc-macro2-diagnostics", + "quote", + "syn 2.0.33", +] [[package]] name = "percent-encoding" @@ -836,7 +718,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" dependencies = [ "fixedbitset", - "indexmap", + "indexmap 1.9.2", ] [[package]] @@ -851,12 +733,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -870,18 +746,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78" dependencies = [ "proc-macro2", - "syn", + "syn 1.0.107", ] [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] +[[package]] +name = "proc-macro2-diagnostics" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.33", + "version_check", + "yansi 1.0.0-rc.1", +] + [[package]] name = "prost" version = "0.11.6" @@ -889,7 +778,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698" dependencies = [ "bytes", - "prost-derive", + "prost-derive 0.11.6", +] + +[[package]] +name = "prost" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fdd22f3b9c31b53c060df4a0613a1c7f062d4115a2b984dd15b1858f7e340d" +dependencies = [ + "bytes", + "prost-derive 0.12.1", ] [[package]] @@ -906,10 +805,10 @@ dependencies = [ "multimap", "petgraph", "prettyplease", - "prost", - "prost-types", + "prost 0.11.6", + "prost-types 0.11.6", "regex", - "syn", + "syn 1.0.107", "tempfile", "which", ] @@ -924,7 +823,20 @@ dependencies = [ "itertools", "proc-macro2", "quote", - "syn", + "syn 1.0.107", +] + +[[package]] +name = "prost-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "265baba7fabd416cf5078179f7d2cbeca4ce7a9041111900675ea7c4cb8a4c32" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.33", ] [[package]] @@ -933,15 +845,24 @@ version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788" dependencies = [ - "bytes", - "prost", + "bytes", + "prost 0.11.6", +] + +[[package]] +name = "prost-types" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e081b29f63d83a4bc75cfc9f3fe424f9156cf92d8a4f0c9407cce9a1b67327cf" +dependencies = [ + "prost 0.12.1", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -982,7 +903,27 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", +] + +[[package]] +name = "ref-cast" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.33", ] [[package]] @@ -996,6 +937,15 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + [[package]] name = "regex-syntax" version = "0.6.28" @@ -1012,12 +962,84 @@ dependencies = [ ] [[package]] -name = "rustc_version" -version = "0.4.0" +name = "rocket" +version = "0.5.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58734f7401ae5cfd129685b48f61182331745b357b96f2367f01aebaf1cc9cc9" +dependencies = [ + "async-stream", + "async-trait", + "atomic", + "binascii", + "bytes", + "either", + "figment", + "futures", + "indexmap 1.9.2", + "is-terminal", + "log", + "memchr", + "multer", + "num_cpus", + "parking_lot", + "pin-project-lite", + "rand", + "ref-cast", + "rocket_codegen", + "rocket_http", + "serde", + "state", + "tempfile", + "time", + "tokio", + "tokio-stream", + "tokio-util", + "ubyte", + "version_check", + "yansi 0.5.1", +] + +[[package]] +name = "rocket_codegen" +version = "0.5.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "7093353f14228c744982e409259fb54878ba9563d08214f2d880d59ff2fc508b" dependencies = [ - "semver", + "devise", + "glob", + "indexmap 1.9.2", + "proc-macro2", + "quote", + "rocket_http", + "syn 2.0.33", + "unicode-xid", +] + +[[package]] +name = "rocket_http" +version = "0.5.0-rc.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936012c99162a03a67f37f9836d5f938f662e26f2717809761a9ac46432090f4" +dependencies = [ + "cookie", + "either", + "futures", + "http", + "hyper", + "indexmap 1.9.2", + "log", + "memchr", + "pear", + "percent-encoding", + "pin-project-lite", + "ref-cast", + "serde", + "smallvec", + "stable-pattern", + "state", + "time", + "tokio", + "uncased", ] [[package]] @@ -1026,7 +1048,7 @@ version = "0.36.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -1034,12 +1056,24 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.1.0" @@ -1047,16 +1081,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] -name = "semver" -version = "1.0.16" +name = "serde" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +dependencies = [ + "serde_derive", +] [[package]] -name = "serde" +name = "serde_derive" version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.107", +] [[package]] name = "serde_json" @@ -1070,26 +1112,21 @@ dependencies = [ ] [[package]] -name = "serde_urlencoded" -version = "0.7.1" +name = "serde_spanned" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" dependencies = [ - "form_urlencoded", - "itoa", - "ryu", "serde", ] [[package]] -name = "sha1" -version = "0.10.5" +name = "sharded-slab" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" dependencies = [ - "cfg-if", - "cpufeatures", - "digest", + "lazy_static", ] [[package]] @@ -1131,24 +1168,50 @@ name = "spawn-examples" version = "0.1.0" dependencies = [ "env_logger", - "prost-types", + "log", + "prost 0.12.1", + "prost-types 0.12.1", + "rocket", "spawn-rs", - "tokio", + "tonic-build", ] [[package]] name = "spawn-rs" version = "0.1.0" dependencies = [ - "actix-protobuf", - "actix-server", - "actix-web", "env_logger", - "prost", - "prost-types", + "log", + "prost 0.12.1", + "prost-types 0.12.1", + "rocket", "tonic-build", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "stable-pattern" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4564168c00635f88eaed410d5efa8131afa8d8699a612c80c455a0ba05c21045" +dependencies = [ + "memchr", +] + +[[package]] +name = "state" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbe866e1e51e8260c9eed836a042a5e7f6726bb2b411dffeaa712e19c388f23b" +dependencies = [ + "loom", +] + [[package]] name = "syn" version = "1.0.107" @@ -1160,6 +1223,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.3.0" @@ -1183,6 +1257,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "time" version = "0.3.17" @@ -1210,21 +1294,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.25.0" @@ -1237,7 +1306,6 @@ dependencies = [ "memchr", "mio", "num_cpus", - "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -1253,7 +1321,18 @@ checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", ] [[package]] @@ -1270,6 +1349,40 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tonic-build" version = "0.8.4" @@ -1280,9 +1393,15 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn", + "syn 1.0.107", ] +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + [[package]] name = "tracing" version = "0.1.37" @@ -1290,11 +1409,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if", - "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.33", +] + [[package]] name = "tracing-core" version = "0.1.30" @@ -1302,52 +1432,96 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ "once_cell", + "valuable", ] [[package]] -name = "typenum" -version = "1.16.0" +name = "tracing-log" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] [[package]] -name = "unicode-bidi" -version = "0.3.10" +name = "tracing-subscriber" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] [[package]] -name = "unicode-ident" -version = "1.0.6" +name = "try-lock" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] -name = "unicode-normalization" -version = "0.1.22" +name = "ubyte" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "c81f0dae7d286ad0d9366d7679a77934cfc3cf3a8d67e82669794412b2368fe6" dependencies = [ - "tinyvec", + "serde", ] [[package]] -name = "url" -version = "2.3.1" +name = "uncased" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", + "serde", + "version_check", ] +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1396,19 +1570,28 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.1", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm 0.42.1", + "windows_x86_64_msvc 0.42.1", ] [[package]] @@ -1417,7 +1600,7 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.1", ] [[package]] @@ -1426,13 +1609,28 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.42.1", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm 0.42.1", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1441,36 +1639,72 @@ version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_i686_gnu" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_msvc" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_x86_64_gnu" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_msvc" version = "0.42.1" @@ -1478,31 +1712,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] -name = "zstd" -version = "0.12.3+zstd.1.5.2" +name = "windows_x86_64_msvc" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76eea132fb024e0e13fd9c2f5d5d595d8a967aa72382ac2f9d39fcc95afd0806" -dependencies = [ - "zstd-safe", -] +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] -name = "zstd-safe" -version = "6.0.4+zstd.1.5.4" +name = "winnow" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7afb4b54b8910cf5447638cb54bf4e8a65cbedd783af98b98c62ffe91f185543" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ - "libc", - "zstd-sys", + "memchr", ] [[package]] -name = "zstd-sys" -version = "2.0.7+zstd.1.5.4" +name = "yansi" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" -dependencies = [ - "cc", - "libc", - "pkg-config", -] +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "yansi" +version = "1.0.0-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1367295b8f788d371ce2dbc842c7b709c73ee1364d30351dd300ec2203b12377" diff --git a/spawn-examples/Cargo.toml b/spawn-examples/Cargo.toml index 3c2207a..061c65c 100644 --- a/spawn-examples/Cargo.toml +++ b/spawn-examples/Cargo.toml @@ -5,6 +5,11 @@ version = "0.1.0" [dependencies] env_logger = "0.10.0" -prost-types = "0.11" +log = {version = "0.4.8", features = ["std"]} +prost = "0.12.1" +prost-types = "0.12.1" +rocket = "=0.5.0-rc.3" spawn-rs = {path = "../spawn-rs"} -tokio = {version = "1.25.0", features = ["full"]} + +[build-dependencies] +tonic-build = "0.8" diff --git a/spawn-examples/build.rs b/spawn-examples/build.rs new file mode 100644 index 0000000..3f53a23 --- /dev/null +++ b/spawn-examples/build.rs @@ -0,0 +1,7 @@ +pub(crate) fn main() -> Result<(), Box> { + tonic_build::configure() + .build_server(false) + .out_dir("src/domain") + .compile(&["proto/domain.proto"], &["proto"])?; + Ok(()) +} diff --git a/spawn-examples/proto/domain.proto b/spawn-examples/proto/domain.proto new file mode 100644 index 0000000..d583bbc --- /dev/null +++ b/spawn-examples/proto/domain.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +package domain; + +message State { + repeated string languages = 1; +} + +message Request { + string language = 1; +} + +message Reply { + string response = 1; +} \ No newline at end of file diff --git a/spawn-examples/src/domain/domain.rs b/spawn-examples/src/domain/domain.rs new file mode 100644 index 0000000..624afcb --- /dev/null +++ b/spawn-examples/src/domain/domain.rs @@ -0,0 +1,18 @@ +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct State { + #[prost(string, repeated, tag = "1")] + pub languages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Request { + #[prost(string, tag = "1")] + pub language: ::prost::alloc::string::String, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct Reply { + #[prost(string, tag = "1")] + pub response: ::prost::alloc::string::String, +} diff --git a/spawn-examples/src/domain/mod.rs b/spawn-examples/src/domain/mod.rs new file mode 100644 index 0000000..d7abca1 --- /dev/null +++ b/spawn-examples/src/domain/mod.rs @@ -0,0 +1 @@ +pub mod domain; diff --git a/spawn-examples/src/joe.rs b/spawn-examples/src/joe.rs index 9372ab5..043500f 100644 --- a/spawn-examples/src/joe.rs +++ b/spawn-examples/src/joe.rs @@ -1,50 +1,26 @@ -use prost_types::Any; +use spawn_examples::domain::domain::{Reply, Request}; +use spawn_rs::{context::Context, value::Value, Message}; -use spawn_rs::{ - action::Action, - actor::{Actor, ActorSettings, Kind}, - context::Context, - serializer::Serializer, - value::Value, - Message, -}; +use log::info; -pub struct Joe; +pub fn set_language(msg: Message, ctx: Context) -> Value { + info!("Actor msg: {:?}", msg); + let value: Value = match msg.body::() { + Ok(request) => { + let lang = request.language; + info!("Setlanguage To: {:?}", lang); + let reply = Reply::default(); -impl Serializer for Joe { - fn decode(&mut self, _msg: prost_types::Any) -> Box { - todo!() - } - - fn encode(&mut self, _msg: Box) -> prost_types::Any { - todo!() - } -} - -impl Actor for Joe { - fn settings(&mut self) -> ActorSettings { - ActorSettings::new() - .name("joe".to_owned()) - .kind(Kind::SINGLETON) - .stateful(true) - .actions(vec!["sum".to_string()]) - .deactivated_timeout(30000) - .snapshot_timeout(10000) - .to_owned() - } -} - -impl Action for Joe { - fn handle(&mut self, msg: Message, ctx: &mut Context) -> Value { - match msg.action() { - "sum" => Value::new() + Value::new() .state(ctx.state().clone()) - .response(Any::default()) - .to_owned(), - _ => Value::new() - .state(Any::default()) - .response(Any::default()) - .to_owned(), + .response(&Reply::default()) + .to_owned() } - } + Err(e) => Value::new() + .state(ctx.state().clone()) + //.response(Any::default()) + .to_owned(), + }; + + return value; } diff --git a/spawn-examples/src/lib.rs b/spawn-examples/src/lib.rs new file mode 100644 index 0000000..95ab638 --- /dev/null +++ b/spawn-examples/src/lib.rs @@ -0,0 +1,5 @@ +#[macro_use] +extern crate log; +extern crate prost_types; + +pub mod domain; diff --git a/spawn-examples/src/main.rs b/spawn-examples/src/main.rs index 6141be9..66f2cb9 100644 --- a/spawn-examples/src/main.rs +++ b/spawn-examples/src/main.rs @@ -1,19 +1,32 @@ extern crate env_logger; extern crate prost_types; -extern crate tokio; +extern crate rocket; mod joe; +use joe::set_language; +use spawn_rs::actor::{ActorDefinition, ActorSettings, Kind}; use spawn_rs::spawn::Spawn; -#[tokio::main] -async fn main() { - env_logger::init_from_env(env_logger::Env::new().default_filter_or("debug")); - +#[rocket::main] +async fn main() -> Result<(), rocket::Error> { Spawn::new() - .system("spawn-system".to_string()) - .port(8091) - .add_actor(Box::new(joe::Joe {})) + .create("spawn-system".to_string()) + .with_actor( + ActorDefinition::new() + .with_settings( + ActorSettings::new() + .name("joe".to_owned()) + .kind(Kind::NAMED) + .stateful(true) + .deactivated_timeout(30000) + .snapshot_timeout(10000) + .to_owned(), + ) + .with_action("sum".to_owned(), set_language), + ) .start() - .await; + .await?; + + Ok(()) } diff --git a/spawn-rs/Cargo.toml b/spawn-rs/Cargo.toml index 1692949..8050207 100644 --- a/spawn-rs/Cargo.toml +++ b/spawn-rs/Cargo.toml @@ -14,12 +14,11 @@ name = "spawn-rs" version = "0.1.0" [dependencies] -actix-protobuf = "0.9.0" -actix-server = "2.2.0" -actix-web = "4" env_logger = "0.10.0" -prost = "0.11" -prost-types = "0.11" +log = {version = "0.4.8", features = ["std"]} +prost = "0.12.1" +prost-types = "0.12.1" +rocket = "=0.5.0-rc.3" [build-dependencies] tonic-build = "0.8" diff --git a/spawn-rs/proto/actor.proto b/spawn-rs/proto/actor.proto index acfc094..f3d4323 100644 --- a/spawn-rs/proto/actor.proto +++ b/spawn-rs/proto/actor.proto @@ -38,27 +38,27 @@ message TimeoutStrategy { int64 timeout = 1; } -// A command represents an action that the user can perform on an Actor. -// Commands in supporting languages are represented by functions or methods. -// An Actor command has nothing to do with the semantics of Commands in a CQRS/EventSourced system. +// A action represents an action that the user can perform on an Actor. +// Actions in supporting languages are represented by functions or methods. +// An Actor action has nothing to do with the semantics of Actions in a CQRS/EventSourced system. // It just represents an action that supporting languages can invoke. -message Command { +message Action { // The name of the function or method in the supporting language that has been registered in Ator. string name = 1; } -// A FixedTimerCommand is similar to a regular Command, its main differences are that it is scheduled to run at regular intervals +// A FixedTimerAction is similar to a regular Action, its main differences are that it is scheduled to run at regular intervals // and only takes the actor's state as an argument. -// Timer Commands are good for executing loops that manipulate the actor's own state. +// Timer Actions are good for executing loops that manipulate the actor's own state. // In Elixir or other languages in BEAM it would be similar to invoking Process.send_after(self(), atom, msg, timeout) -message FixedTimerCommand { +message FixedTimerAction { - // The time to wait until the command is triggered + // The time to wait until the action is triggered int32 seconds = 1; - // See Command description Above - Command command = 2; + // See Action description Above + Action action = 2; } message ActorState { @@ -68,7 +68,7 @@ message ActorState { // TODO doc here message Metadata { - // A channel group represents a way to send commands to various actors + // A channel group represents a way to send actions to various actors // that belong to a certain semantic group. string channel_group = 1; @@ -79,17 +79,17 @@ message Metadata { // Regardless of the type of actor it is important that // all actors are registered during the proxy and host initialization phase. enum Kind { - // When no type is informed, the default to be assumed will be the Singleton pattern. + // When no type is informed, the default to be assumed will be the Named pattern. UNKNOW_KIND = 0; - // Abstract actors are used to create children of this based actor at runtime - ABSTRACT = 1; + // NAMED actors are used to create children of this based actor at runtime + NAMED = 1; - // Singleton actors as the name suggests have only one real instance of themselves running - // during their entire lifecycle. That is, they are the opposite of the Abstract type Actors. - SINGLETON = 2; + // UNAMED actors as the name suggests have only one real instance of themselves running + // during their entire lifecycle. That is, they are the opposite of the NAMED type Actors. + UNAMED = 2; - // Pooled Actors are similar to abstract actors, but unlike them, + // Pooled Actors are similar to Unamed actors, but unlike them, // their identifying name will always be the one registered at the system initialization stage. // The great advantage of Pooled actors is that they have multiple instances of themselves // acting as a request service pool. @@ -134,7 +134,7 @@ message ActorId { // Name of a ActorSystem string system = 2; - // When the Actor is of the Abstract type, + // When the Actor is of the Unamed type, // the name of the parent Actor must be informed here. string parent = 3; } @@ -152,9 +152,9 @@ message Actor { // Actor settings. ActorSettings settings = 3; - // The commands registered for an actor - repeated Command commands = 4; + // The actions registered for an actor + repeated Action actions = 4; - // The registered timer commands for an actor. - repeated FixedTimerCommand timer_commands = 5; + // The registered timer actions for an actor. + repeated FixedTimerAction timer_actions = 5; } \ No newline at end of file diff --git a/spawn-rs/proto/protocol.proto b/spawn-rs/proto/protocol.proto index f0d6823..8589a62 100644 --- a/spawn-rs/proto/protocol.proto +++ b/spawn-rs/proto/protocol.proto @@ -58,7 +58,7 @@ // // Actors are usually created at the beginning of the SDK's communication flow with the Proxy by the registration step described above. // However, some use cases require that Actors can be created ***on the fly***. -// In other words, Spawn is used to bring to life Actors previously registered as Abstracts, giving them a name and thus creating a concrete instance +// In other words, Spawn is used to bring to life Actors previously registered as Unameds, giving them a name and thus creating a concrete instance // at runtime for that Actor. Actors created with the Spawn feature are generally used when you want to share a behavior while maintaining // the isolation characteristics of the actors. // For these situations we have the Spawning flow described below. @@ -135,7 +135,7 @@ // ║ ║ ║ ║ // ║ ║ ╠───┐ ║ // ║ ║ ║ │Handle request, ║ -// ║ ║ ║ │execute command ║ +// ║ ║ ║ │execute action ║ // ║ ║ ║◀──┘ ║ // ║ ║ ║ Reply with the ║ // ║ ║ ╠────────────result and the ────────▶║ @@ -192,6 +192,12 @@ message Context { // he does not care about the input value only with the state. message Noop {} +// JSON is an alternative that some SDKs can opt in +// it will bypass any type validation in spawn actors state / payloads +message JSONType { + string content = 1; +} + message RegistrationRequest { ServiceInfo service_info = 1; @@ -271,8 +277,8 @@ message Broadcast { // Channel of target Actors string channel_group = 1; - // Command. Only Actors that have this command will run successfully - string command_name = 2; + // Action. Only Actors that have this action will run successfully + string action_name = 2; // Payload oneof payload { @@ -281,26 +287,26 @@ message Broadcast { } } -// Sends the output of a command of an Actor to the input of another command of an Actor +// Sends the output of a action of an Actor to the input of another action of an Actor // Useful for handle `pipes` pattern: // https://www.enterpriseintegrationpatterns.com/patterns/messaging/PipesAndFilters.html message Pipe { // Target Actor string actor = 1; - // Command. - string command_name = 2; + // Action. + string action_name = 2; } -// Sends the input of a command of an Actor to the input of another command of an Actor +// Sends the input of a action of an Actor to the input of another action of an Actor // Useful for handle `content-basead router` pattern // https://www.enterpriseintegrationpatterns.com/patterns/messaging/ContentBasedRouter.html message Forward { // Target Actor string actor = 1; - // Command. - string command_name = 2; + // Action. + string action_name = 2; } // Container for archicetural message patterns @@ -322,11 +328,11 @@ message Workflow { // * system: See ActorSystem message. // * actor: The target Actor, i.e. the one that the user function is calling to perform some computation. // * caller: The caller Actor -// * command_name: The function or method on the target Actor that will receive this request +// * action_name: The function or method on the target Actor that will receive this request // and perform some useful computation with the sent data. -// * value: This is the value sent by the user function to be computed by the request's target Actor command. -// * async: Indicates whether the command should be processed synchronously, where a response should be sent back to the user function, -// or whether the command should be processed asynchronously, i.e. no response sent to the caller and no waiting. +// * value: This is the value sent by the user function to be computed by the request's target Actor action. +// * async: Indicates whether the action should be processed synchronously, where a response should be sent back to the user function, +// or whether the action should be processed asynchronously, i.e. no response sent to the caller and no waiting. // * metadata: Meta information or headers message InvocationRequest { @@ -334,7 +340,7 @@ message InvocationRequest { eigr.spawn.Actor actor = 2; - string command_name = 3; + string action_name = 3; oneof payload { google.protobuf.Any value = 4; @@ -357,17 +363,17 @@ message InvocationRequest { // // Params: // * actor: The ActorId handling the InvocationRequest request, also called the target Actor. -// * command_name: The function or method on the target Actor that will receive this request +// * action_name: The function or method on the target Actor that will receive this request // and perform some useful computation with the sent data. // * current_context: The current Context with current state value of the target Actor. // That is, the same as found via matching in %Actor{name: target_actor, state: %ActorState{state: value} = actor_state}. // In this case, the Context type will contain in the value attribute the same `value` as the matching above. -// * payload: The value to be passed to the function or method corresponding to command_name. +// * payload: The value to be passed to the function or method corresponding to action_name. message ActorInvocation { eigr.spawn.ActorId actor = 1; - string command_name = 2; + string action_name = 2; Context current_context = 3; @@ -401,6 +407,8 @@ message ActorInvocationResponse { } Workflow workflow = 5; + + bool checkpoint = 7; } // InvocationResponse is the response that the proxy that received the InvocationRequest request will forward to the request's original user function. @@ -442,4 +450,3 @@ message RequestStatus { string message = 2; } - diff --git a/spawn-rs/src/action.rs b/spawn-rs/src/action.rs deleted file mode 100644 index 30d1aea..0000000 --- a/spawn-rs/src/action.rs +++ /dev/null @@ -1,10 +0,0 @@ -use crate::{actor::Actor, context::Context, value::Value, Message}; - -#[allow(unused_variables)] -pub trait Action -where - Self: Actor, -{ - /// This method is called for every message received by this actor. - fn handle(&mut self, msg: Message, ctx: &mut Context) -> Value; -} diff --git a/spawn-rs/src/actor.rs b/spawn-rs/src/actor.rs index 15b6736..851d77b 100644 --- a/spawn-rs/src/actor.rs +++ b/spawn-rs/src/actor.rs @@ -1,7 +1,12 @@ +use crate::Message; +use crate::{context::Context, value::Value}; + +use std::collections::HashMap; + #[derive(Debug, Clone)] pub enum Kind { - ABSTRACT, - SINGLETON, + NAMED, + UNNAMED, POOLED, PROXY, } @@ -9,7 +14,6 @@ pub enum Kind { #[derive(Debug, Clone)] pub struct ActorSettings { name: String, - actions: Vec, kind: Kind, stateful: bool, deactivated_timeout: i64, @@ -23,8 +27,7 @@ impl Default for ActorSettings { fn default() -> ActorSettings { ActorSettings { name: String::from(""), - kind: Kind::SINGLETON, - actions: Vec::new(), + kind: Kind::NAMED, stateful: true, deactivated_timeout: 60000, snapshot_timeout: 50000, @@ -50,11 +53,6 @@ impl ActorSettings { self } - pub fn actions(&mut self, actions: Vec) -> &mut ActorSettings { - self.actions = actions; - self - } - pub fn stateful(&mut self, stateful: bool) -> &mut ActorSettings { self.stateful = stateful; self @@ -84,10 +82,79 @@ impl ActorSettings { self.max_pool_size = size; self } + + pub fn get_name(&mut self) -> String { + self.name.to_string() + } + + pub fn get_kind(&mut self) -> &mut Kind { + &mut self.kind + } + + pub fn get_stateful(&mut self) -> bool { + self.stateful + } + + pub fn get_deactivated_timeout(&mut self) -> i64 { + self.deactivated_timeout + } + + pub fn get_snapshot_timeout(&mut self) -> i64 { + self.snapshot_timeout + } + + pub fn get_channel(&mut self) -> String { + self.channel.to_string() + } + + pub fn get_min_pool_size(&mut self) -> i32 { + self.min_pool_size + } + + pub fn get_max_pool_size(&mut self) -> i32 { + self.max_pool_size + } +} + +#[derive(Clone)] +pub struct ActorDefinition { + settings: ActorSettings, + actions: HashMap Value>, +} + +impl Default for ActorDefinition { + fn default() -> ActorDefinition { + ActorDefinition { + actions: HashMap::new(), + settings: ActorSettings::new(), + } + } } -/// Actor trait -#[allow(unused_variables)] -pub trait Actor { - fn settings(&mut self) -> ActorSettings; +impl ActorDefinition { + pub fn new() -> Self { + Default::default() + } + + pub fn with_settings(&mut self, settings: ActorSettings) -> &mut ActorDefinition { + self.settings = settings; + self + } + + pub fn with_action( + &mut self, + name: String, + action: fn(Message, Context) -> Value, + ) -> &mut ActorDefinition { + self.actions.insert(name, action); + self + } + + pub fn get_settings(&mut self) -> &mut ActorSettings { + &mut self.settings + } + + pub fn get_actions(&mut self) -> &mut HashMap Value> { + &mut self.actions + } } diff --git a/spawn-rs/src/context.rs b/spawn-rs/src/context.rs index aa68d8e..ebee38c 100644 --- a/spawn-rs/src/context.rs +++ b/spawn-rs/src/context.rs @@ -5,7 +5,19 @@ pub struct Context { state: Any, } +impl Default for Context { + fn default() -> Context { + Context { + state: Any::default(), + } + } +} + impl Context { + pub fn new() -> Self { + Default::default() + } + /// Returns a reference to the state of this [`Context`]. pub fn state(&self) -> &Any { &self.state diff --git a/spawn-rs/src/eigr/eigr.spawn.rs b/spawn-rs/src/eigr/eigr.spawn.rs index 39fa9c4..53c19f7 100644 --- a/spawn-rs/src/eigr/eigr.spawn.rs +++ b/spawn-rs/src/eigr/eigr.spawn.rs @@ -54,30 +54,30 @@ pub struct TimeoutStrategy { #[prost(int64, tag = "1")] pub timeout: i64, } -/// A command represents an action that the user can perform on an Actor. -/// Commands in supporting languages are represented by functions or methods. -/// An Actor command has nothing to do with the semantics of Commands in a CQRS/EventSourced system. +/// A action represents an action that the user can perform on an Actor. +/// Actions in supporting languages are represented by functions or methods. +/// An Actor action has nothing to do with the semantics of Actions in a CQRS/EventSourced system. /// It just represents an action that supporting languages can invoke. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct Command { +pub struct Action { /// The name of the function or method in the supporting language that has been registered in Ator. #[prost(string, tag = "1")] pub name: ::prost::alloc::string::String, } -/// A FixedTimerCommand is similar to a regular Command, its main differences are that it is scheduled to run at regular intervals +/// A FixedTimerAction is similar to a regular Action, its main differences are that it is scheduled to run at regular intervals /// and only takes the actor's state as an argument. -/// Timer Commands are good for executing loops that manipulate the actor's own state. +/// Timer Actions are good for executing loops that manipulate the actor's own state. /// In Elixir or other languages in BEAM it would be similar to invoking Process.send_after(self(), atom, msg, timeout) #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct FixedTimerCommand { - /// The time to wait until the command is triggered +pub struct FixedTimerAction { + /// The time to wait until the action is triggered #[prost(int32, tag = "1")] pub seconds: i32, - /// See Command description Above + /// See Action description Above #[prost(message, optional, tag = "2")] - pub command: ::core::option::Option, + pub action: ::core::option::Option, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -94,7 +94,7 @@ pub struct ActorState { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Metadata { - /// A channel group represents a way to send commands to various actors + /// A channel group represents a way to send actions to various actors /// that belong to a certain semantic group. #[prost(string, tag = "1")] pub channel_group: ::prost::alloc::string::String, @@ -135,7 +135,7 @@ pub struct ActorId { /// Name of a ActorSystem #[prost(string, tag = "2")] pub system: ::prost::alloc::string::String, - /// When the Actor is of the Abstract type, + /// When the Actor is of the Unamed type, /// the name of the parent Actor must be informed here. #[prost(string, tag = "3")] pub parent: ::prost::alloc::string::String, @@ -155,12 +155,12 @@ pub struct Actor { /// Actor settings. #[prost(message, optional, tag = "3")] pub settings: ::core::option::Option, - /// The commands registered for an actor + /// The actions registered for an actor #[prost(message, repeated, tag = "4")] - pub commands: ::prost::alloc::vec::Vec, - /// The registered timer commands for an actor. + pub actions: ::prost::alloc::vec::Vec, + /// The registered timer actions for an actor. #[prost(message, repeated, tag = "5")] - pub timer_commands: ::prost::alloc::vec::Vec, + pub timer_actions: ::prost::alloc::vec::Vec, } /// The type that defines the runtime characteristics of the Actor. /// Regardless of the type of actor it is important that @@ -168,14 +168,14 @@ pub struct Actor { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum Kind { - /// When no type is informed, the default to be assumed will be the Singleton pattern. + /// When no type is informed, the default to be assumed will be the Named pattern. UnknowKind = 0, - /// Abstract actors are used to create children of this based actor at runtime - Abstract = 1, - /// Singleton actors as the name suggests have only one real instance of themselves running - /// during their entire lifecycle. That is, they are the opposite of the Abstract type Actors. - Singleton = 2, - /// Pooled Actors are similar to abstract actors, but unlike them, + /// NAMED actors are used to create children of this based actor at runtime + Named = 1, + /// UNAMED actors as the name suggests have only one real instance of themselves running + /// during their entire lifecycle. That is, they are the opposite of the NAMED type Actors. + Unamed = 2, + /// Pooled Actors are similar to Unamed actors, but unlike them, /// their identifying name will always be the one registered at the system initialization stage. /// The great advantage of Pooled actors is that they have multiple instances of themselves /// acting as a request service pool. @@ -198,8 +198,8 @@ impl Kind { pub fn as_str_name(&self) -> &'static str { match self { Kind::UnknowKind => "UNKNOW_KIND", - Kind::Abstract => "ABSTRACT", - Kind::Singleton => "SINGLETON", + Kind::Named => "NAMED", + Kind::Unamed => "UNAMED", Kind::Pooled => "POOLED", Kind::Proxy => "PROXY", } @@ -208,8 +208,8 @@ impl Kind { pub fn from_str_name(value: &str) -> ::core::option::Option { match value { "UNKNOW_KIND" => Some(Self::UnknowKind), - "ABSTRACT" => Some(Self::Abstract), - "SINGLETON" => Some(Self::Singleton), + "NAMED" => Some(Self::Named), + "UNAMED" => Some(Self::Unamed), "POOLED" => Some(Self::Pooled), "PROXY" => Some(Self::Proxy), _ => None, @@ -254,6 +254,14 @@ pub struct Context { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Noop {} +/// JSON is an alternative that some SDKs can opt in +/// it will bypass any type validation in spawn actors state / payloads +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct JsonType { + #[prost(string, tag = "1")] + pub content: ::prost::alloc::string::String, +} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RegistrationRequest { @@ -345,9 +353,9 @@ pub struct Broadcast { /// Channel of target Actors #[prost(string, tag = "1")] pub channel_group: ::prost::alloc::string::String, - /// Command. Only Actors that have this command will run successfully + /// Action. Only Actors that have this action will run successfully #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, /// Payload #[prost(oneof = "broadcast::Payload", tags = "3, 4")] pub payload: ::core::option::Option, @@ -364,7 +372,7 @@ pub mod broadcast { Noop(super::Noop), } } -/// Sends the output of a command of an Actor to the input of another command of an Actor +/// Sends the output of a action of an Actor to the input of another action of an Actor /// Useful for handle `pipes` pattern: /// #[allow(clippy::derive_partial_eq_without_eq)] @@ -373,11 +381,11 @@ pub struct Pipe { /// Target Actor #[prost(string, tag = "1")] pub actor: ::prost::alloc::string::String, - /// Command. + /// Action. #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, } -/// Sends the input of a command of an Actor to the input of another command of an Actor +/// Sends the input of a action of an Actor to the input of another action of an Actor /// Useful for handle `content-basead router` pattern /// #[allow(clippy::derive_partial_eq_without_eq)] @@ -386,9 +394,9 @@ pub struct Forward { /// Target Actor #[prost(string, tag = "1")] pub actor: ::prost::alloc::string::String, - /// Command. + /// Action. #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, } /// Container for archicetural message patterns #[allow(clippy::derive_partial_eq_without_eq)] @@ -418,11 +426,11 @@ pub mod workflow { /// * system: See ActorSystem message. /// * actor: The target Actor, i.e. the one that the user function is calling to perform some computation. /// * caller: The caller Actor -/// * command_name: The function or method on the target Actor that will receive this request +/// * action_name: The function or method on the target Actor that will receive this request /// and perform some useful computation with the sent data. -/// * value: This is the value sent by the user function to be computed by the request's target Actor command. -/// * async: Indicates whether the command should be processed synchronously, where a response should be sent back to the user function, -/// or whether the command should be processed asynchronously, i.e. no response sent to the caller and no waiting. +/// * value: This is the value sent by the user function to be computed by the request's target Actor action. +/// * async: Indicates whether the action should be processed synchronously, where a response should be sent back to the user function, +/// or whether the action should be processed asynchronously, i.e. no response sent to the caller and no waiting. /// * metadata: Meta information or headers #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -432,7 +440,7 @@ pub struct InvocationRequest { #[prost(message, optional, tag = "2")] pub actor: ::core::option::Option, #[prost(string, tag = "3")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, #[prost(bool, tag = "5")] pub r#async: bool, #[prost(message, optional, tag = "6")] @@ -465,19 +473,19 @@ pub mod invocation_request { /// /// Params: /// * actor: The ActorId handling the InvocationRequest request, also called the target Actor. -/// * command_name: The function or method on the target Actor that will receive this request +/// * action_name: The function or method on the target Actor that will receive this request /// and perform some useful computation with the sent data. /// * current_context: The current Context with current state value of the target Actor. /// That is, the same as found via matching in %Actor{name: target_actor, state: %ActorState{state: value} = actor_state}. /// In this case, the Context type will contain in the value attribute the same `value` as the matching above. -/// * payload: The value to be passed to the function or method corresponding to command_name. +/// * payload: The value to be passed to the function or method corresponding to action_name. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ActorInvocation { #[prost(message, optional, tag = "1")] pub actor: ::core::option::Option, #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, #[prost(message, optional, tag = "3")] pub current_context: ::core::option::Option, #[prost(message, optional, tag = "6")] @@ -515,6 +523,8 @@ pub struct ActorInvocationResponse { pub updated_context: ::core::option::Option, #[prost(message, optional, tag = "5")] pub workflow: ::core::option::Option, + #[prost(bool, tag = "7")] + pub checkpoint: bool, #[prost(oneof = "actor_invocation_response::Payload", tags = "4, 6")] pub payload: ::core::option::Option, } diff --git a/spawn-rs/src/eigr/spawn.rs b/spawn-rs/src/eigr/spawn.rs index b92cec8..d83e964 100644 --- a/spawn-rs/src/eigr/spawn.rs +++ b/spawn-rs/src/eigr/spawn.rs @@ -54,30 +54,30 @@ pub struct TimeoutStrategy { #[prost(int64, tag = "1")] pub timeout: i64, } -/// A command represents an action that the user can perform on an Actor. -/// Commands in supporting languages are represented by functions or methods. -/// An Actor command has nothing to do with the semantics of Commands in a CQRS/EventSourced system. +/// A action represents an action that the user can perform on an Actor. +/// Actions in supporting languages are represented by functions or methods. +/// An Actor action has nothing to do with the semantics of Actions in a CQRS/EventSourced system. /// It just represents an action that supporting languages can invoke. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct Command { +pub struct Action { /// The name of the function or method in the supporting language that has been registered in Ator. #[prost(string, tag = "1")] pub name: ::prost::alloc::string::String, } -/// A FixedTimerCommand is similar to a regular Command, its main differences are that it is scheduled to run at regular intervals +/// A FixedTimerAction is similar to a regular Action, its main differences are that it is scheduled to run at regular intervals /// and only takes the actor's state as an argument. -/// Timer Commands are good for executing loops that manipulate the actor's own state. +/// Timer Actions are good for executing loops that manipulate the actor's own state. /// In Elixir or other languages in BEAM it would be similar to invoking Process.send_after(self(), atom, msg, timeout) #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] -pub struct FixedTimerCommand { - /// The time to wait until the command is triggered +pub struct FixedTimerAction { + /// The time to wait until the action is triggered #[prost(int32, tag = "1")] pub seconds: i32, - /// See Command description Above + /// See Action description Above #[prost(message, optional, tag = "2")] - pub command: ::core::option::Option, + pub action: ::core::option::Option, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -92,7 +92,7 @@ pub struct ActorState { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Metadata { - /// A channel group represents a way to send commands to various actors + /// A channel group represents a way to send actions to various actors /// that belong to a certain semantic group. #[prost(string, tag = "1")] pub channel_group: ::prost::alloc::string::String, @@ -131,7 +131,7 @@ pub struct ActorId { /// Name of a ActorSystem #[prost(string, tag = "2")] pub system: ::prost::alloc::string::String, - /// When the Actor is of the Abstract type, + /// When the Actor is of the Unamed type, /// the name of the parent Actor must be informed here. #[prost(string, tag = "3")] pub parent: ::prost::alloc::string::String, @@ -151,12 +151,12 @@ pub struct Actor { /// Actor settings. #[prost(message, optional, tag = "3")] pub settings: ::core::option::Option, - /// The commands registered for an actor + /// The actions registered for an actor #[prost(message, repeated, tag = "4")] - pub commands: ::prost::alloc::vec::Vec, - /// The registered timer commands for an actor. + pub actions: ::prost::alloc::vec::Vec, + /// The registered timer actions for an actor. #[prost(message, repeated, tag = "5")] - pub timer_commands: ::prost::alloc::vec::Vec, + pub timer_actions: ::prost::alloc::vec::Vec, } /// The type that defines the runtime characteristics of the Actor. /// Regardless of the type of actor it is important that @@ -164,14 +164,14 @@ pub struct Actor { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum Kind { - /// When no type is informed, the default to be assumed will be the Singleton pattern. + /// When no type is informed, the default to be assumed will be the Named pattern. UnknowKind = 0, - /// Abstract actors are used to create children of this based actor at runtime - Abstract = 1, - /// Singleton actors as the name suggests have only one real instance of themselves running - /// during their entire lifecycle. That is, they are the opposite of the Abstract type Actors. - Singleton = 2, - /// Pooled Actors are similar to abstract actors, but unlike them, + /// NAMED actors are used to create children of this based actor at runtime + Named = 1, + /// UNAMED actors as the name suggests have only one real instance of themselves running + /// during their entire lifecycle. That is, they are the opposite of the NAMED type Actors. + Unamed = 2, + /// Pooled Actors are similar to Unamed actors, but unlike them, /// their identifying name will always be the one registered at the system initialization stage. /// The great advantage of Pooled actors is that they have multiple instances of themselves /// acting as a request service pool. @@ -194,8 +194,8 @@ impl Kind { pub fn as_str_name(&self) -> &'static str { match self { Kind::UnknowKind => "UNKNOW_KIND", - Kind::Abstract => "ABSTRACT", - Kind::Singleton => "SINGLETON", + Kind::Named => "NAMED", + Kind::Unamed => "UNAMED", Kind::Pooled => "POOLED", Kind::Proxy => "PROXY", } @@ -204,8 +204,8 @@ impl Kind { pub fn from_str_name(value: &str) -> ::core::option::Option { match value { "UNKNOW_KIND" => Some(Self::UnknowKind), - "ABSTRACT" => Some(Self::Abstract), - "SINGLETON" => Some(Self::Singleton), + "NAMED" => Some(Self::Named), + "UNAMED" => Some(Self::Unamed), "POOLED" => Some(Self::Pooled), "PROXY" => Some(Self::Proxy), _ => None, @@ -246,6 +246,14 @@ pub struct Context { #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Noop {} +/// JSON is an alternative that some SDKs can opt in +/// it will bypass any type validation in spawn actors state / payloads +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct JsonType { + #[prost(string, tag = "1")] + pub content: ::prost::alloc::string::String, +} #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct RegistrationRequest { @@ -337,9 +345,9 @@ pub struct Broadcast { /// Channel of target Actors #[prost(string, tag = "1")] pub channel_group: ::prost::alloc::string::String, - /// Command. Only Actors that have this command will run successfully + /// Action. Only Actors that have this action will run successfully #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, /// Payload #[prost(oneof = "broadcast::Payload", tags = "3, 4")] pub payload: ::core::option::Option, @@ -356,7 +364,7 @@ pub mod broadcast { Noop(super::Noop), } } -/// Sends the output of a command of an Actor to the input of another command of an Actor +/// Sends the output of a action of an Actor to the input of another action of an Actor /// Useful for handle `pipes` pattern: /// #[allow(clippy::derive_partial_eq_without_eq)] @@ -365,11 +373,11 @@ pub struct Pipe { /// Target Actor #[prost(string, tag = "1")] pub actor: ::prost::alloc::string::String, - /// Command. + /// Action. #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, } -/// Sends the input of a command of an Actor to the input of another command of an Actor +/// Sends the input of a action of an Actor to the input of another action of an Actor /// Useful for handle `content-basead router` pattern /// #[allow(clippy::derive_partial_eq_without_eq)] @@ -378,9 +386,9 @@ pub struct Forward { /// Target Actor #[prost(string, tag = "1")] pub actor: ::prost::alloc::string::String, - /// Command. + /// Action. #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, } /// Container for archicetural message patterns #[allow(clippy::derive_partial_eq_without_eq)] @@ -410,11 +418,11 @@ pub mod workflow { /// * system: See ActorSystem message. /// * actor: The target Actor, i.e. the one that the user function is calling to perform some computation. /// * caller: The caller Actor -/// * command_name: The function or method on the target Actor that will receive this request +/// * action_name: The function or method on the target Actor that will receive this request /// and perform some useful computation with the sent data. -/// * value: This is the value sent by the user function to be computed by the request's target Actor command. -/// * async: Indicates whether the command should be processed synchronously, where a response should be sent back to the user function, -/// or whether the command should be processed asynchronously, i.e. no response sent to the caller and no waiting. +/// * value: This is the value sent by the user function to be computed by the request's target Actor action. +/// * async: Indicates whether the action should be processed synchronously, where a response should be sent back to the user function, +/// or whether the action should be processed asynchronously, i.e. no response sent to the caller and no waiting. /// * metadata: Meta information or headers #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -424,7 +432,7 @@ pub struct InvocationRequest { #[prost(message, optional, tag = "2")] pub actor: ::core::option::Option, #[prost(string, tag = "3")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, #[prost(bool, tag = "5")] pub r#async: bool, #[prost(message, optional, tag = "6")] @@ -455,19 +463,19 @@ pub mod invocation_request { /// /// Params: /// * actor: The ActorId handling the InvocationRequest request, also called the target Actor. -/// * command_name: The function or method on the target Actor that will receive this request +/// * action_name: The function or method on the target Actor that will receive this request /// and perform some useful computation with the sent data. /// * current_context: The current Context with current state value of the target Actor. /// That is, the same as found via matching in %Actor{name: target_actor, state: %ActorState{state: value} = actor_state}. /// In this case, the Context type will contain in the value attribute the same `value` as the matching above. -/// * payload: The value to be passed to the function or method corresponding to command_name. +/// * payload: The value to be passed to the function or method corresponding to action_name. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct ActorInvocation { #[prost(message, optional, tag = "1")] pub actor: ::core::option::Option, #[prost(string, tag = "2")] - pub command_name: ::prost::alloc::string::String, + pub action_name: ::prost::alloc::string::String, #[prost(message, optional, tag = "3")] pub current_context: ::core::option::Option, #[prost(message, optional, tag = "6")] @@ -505,6 +513,8 @@ pub struct ActorInvocationResponse { pub updated_context: ::core::option::Option, #[prost(message, optional, tag = "5")] pub workflow: ::core::option::Option, + #[prost(bool, tag = "7")] + pub checkpoint: bool, #[prost(oneof = "actor_invocation_response::Payload", tags = "4, 6")] pub payload: ::core::option::Option, } diff --git a/spawn-rs/src/handler/actor_router.rs b/spawn-rs/src/handler/actor_router.rs new file mode 100644 index 0000000..8642322 --- /dev/null +++ b/spawn-rs/src/handler/actor_router.rs @@ -0,0 +1,93 @@ +use std::collections::HashMap; + +use crate::actor::ActorDefinition; + +use crate::context::Context as ActorContext; +use crate::eigr::spawn::actor_invocation::Payload; +use crate::eigr::spawn::{ActorId, ActorInvocation, ActorInvocationResponse, Context, Noop}; +use crate::value::Value; +use crate::Message as ActorMessage; + +use log::{debug, info}; +use prost_types::Any; + +#[derive()] +pub struct Handler { + actors: HashMap, +} + +impl Default for Handler { + fn default() -> Handler { + Handler { + actors: HashMap::new(), + } + } +} + +impl Handler { + pub fn new() -> Self { + Default::default() + } + + pub fn add_actors(&mut self, actors: &mut Vec) -> &mut Handler { + for def in actors.iter() { + let mut actor = def.to_owned(); + let settings = actor.get_settings(); + let name = settings.get_name(); + + self.actors.insert(name.to_owned(), actor); + } + + self + } + + pub fn get_actors(&mut self) -> &mut HashMap { + &mut self.actors + } + + pub fn handle(&mut self, request: ActorInvocation) -> ActorInvocationResponse { + info!("Received ActorInvocation request."); + debug!( + "Handle ActorInvocation with incoming request: {:?}", + request + ); + + let actor_id: ActorId = request.actor.unwrap(); + let action: String = request.action_name; + let context: Context = request.current_context.unwrap(); + + let response = ActorInvocationResponse::default(); + + if self.actors.contains_key(actor_id.name.as_str()) { + debug!( + "Forward ActorInvocation to Actor: {:?}", + actor_id.name.as_str() + ); + // handle response + let mut actor_def = self.actors.get(actor_id.name.as_str()).unwrap().clone(); + + if actor_def.get_actions().contains_key(action.as_str()) { + let function: &fn(ActorMessage, ActorContext) -> Value = + actor_def.get_actions().get(action.as_str()).unwrap(); + + let payload = match request.payload { + Some(Payload::Value(value)) => value, + Some(Payload::Noop(_)) => Any::default(), + None => Any::default(), + }; + + let mut msg: ActorMessage = ActorMessage::new(); + msg.set_body(payload); + + let ctx: ActorContext = ActorContext::new(); + + let result: Value = (function)(msg, ctx); + + // TODO: build correct response + return response; + } + } + + return response; + } +} diff --git a/spawn-rs/src/handler/callback.rs b/spawn-rs/src/handler/callback.rs deleted file mode 100644 index 885bd90..0000000 --- a/spawn-rs/src/handler/callback.rs +++ /dev/null @@ -1,19 +0,0 @@ -pub mod v1 { - use std::cell::Cell; - - use crate::actor::Actor; - use crate::eigr::spawn::ActorInvocation; - - use actix_protobuf::ProtoBuf; - use actix_web::{http::header::ContentType, post, web::Data, HttpResponse, Responder}; - - #[post("/actions")] - pub async fn handle( - ctx: Data>>>, - req: ProtoBuf, - ) -> impl Responder { - HttpResponse::Ok() - .content_type(ContentType::plaintext()) - .body(format!("Hello !")) - } -} diff --git a/spawn-rs/src/handler/mod.rs b/spawn-rs/src/handler/mod.rs index b5da7c5..6303762 100644 --- a/spawn-rs/src/handler/mod.rs +++ b/spawn-rs/src/handler/mod.rs @@ -1 +1 @@ -pub mod callback; +pub mod actor_router; diff --git a/spawn-rs/src/lib.rs b/spawn-rs/src/lib.rs index 1a1fd05..5d9f614 100644 --- a/spawn-rs/src/lib.rs +++ b/spawn-rs/src/lib.rs @@ -1,9 +1,10 @@ -extern crate actix_web; +#[macro_use] +extern crate rocket; +extern crate log; extern crate prost_types; mod eigr; -pub mod action; pub mod actor; pub mod context; pub mod handler; @@ -11,18 +12,34 @@ pub mod serializer; pub mod spawn; pub mod value; +use prost::DecodeError; use prost_types::Any; +// fn to_any(message: &T) -> Any +// where +// T: prost::Message, +// { +// Any { +// type_url: T::type_url().to_string(), +// value: message.encode_to_vec(), +// } +// } + +fn from_any(message: &Any) -> Result +where + T: prost::Message + Default, +{ + T::decode(message.value.as_slice()) +} + #[derive(Debug, Clone)] pub struct Message { - action: String, body: Any, } impl Default for Message { fn default() -> Message { Message { - action: String::from(""), body: Any::default(), } } @@ -33,11 +50,14 @@ impl Message { Default::default() } - pub fn action(&self) -> &str { - &self.action + pub fn body(&self) -> Result + where + T: prost::Message + Default, + { + from_any(&self.body) } - pub fn body(&self) -> &Any { - &self.body + pub fn set_body(&mut self, message: Any) { + self.body = message } } diff --git a/spawn-rs/src/serializer.rs b/spawn-rs/src/serializer.rs index a664f20..1458089 100644 --- a/spawn-rs/src/serializer.rs +++ b/spawn-rs/src/serializer.rs @@ -1,12 +1,12 @@ -use crate::actor::Actor; +// use crate::actor::Actor; -#[allow(unused_variables)] -pub trait Serializer -where - Self: Actor, -{ - /// This method is called for every message received by this actor. - fn decode(&mut self, msg: prost_types::Any) -> Box; +// #[allow(unused_variables)] +// pub trait Serializer +// where +// Self: Actor, +// { +// /// This method is called for every message received by this actor. +// fn decode(&mut self, msg: prost_types::Any) -> Box; - fn encode(&mut self, msg: Box) -> prost_types::Any; -} +// fn encode(&mut self, msg: Box) -> prost_types::Any; +// } diff --git a/spawn-rs/src/spawn.rs b/spawn-rs/src/spawn.rs index d071ef0..f15812b 100644 --- a/spawn-rs/src/spawn.rs +++ b/spawn-rs/src/spawn.rs @@ -1,83 +1,83 @@ -use crate::actor::Actor; -use crate::handler::callback; +use crate::actor::ActorDefinition; +use crate::eigr::spawn::{ActorInvocation, ActorInvocationResponse}; +use crate::handler::actor_router::Handler; -use std::{cell::Cell, io::Result}; +use prost::Message; +use rocket::post; -use actix_web::{ - middleware, - web::{self, Data}, - App, HttpServer, -}; +use rocket::data::{Data, ToByteUnit}; +use rocket::State; +use std::io; +use std::io::Cursor; +use std::sync::{Arc, Mutex}; + +#[post( + "/api/v1/actors/actions", + format = "application/octet-stream", + data = "" +)] +async fn handle(data: Data<'_>, handler: &State>>) -> io::Result> { + let bytes = data.open(2048.megabytes()).into_bytes().await?; + + let request_handler = Arc::clone(&handler); + + let buffer = bytes.into_inner(); + let request: ActorInvocation = ActorInvocation::decode(&mut Cursor::new(buffer)).unwrap(); + + let mut buf: Vec = Vec::new(); + let response: ActorInvocationResponse = request_handler.lock().unwrap().handle(request); + response.encode(&mut buf).unwrap(); + return Ok(buf); +} + +#[derive()] pub struct Spawn { system: String, - actors: Vec>, - server_port: u16, + actors: Vec, } impl Default for Spawn { fn default() -> Spawn { Spawn { - actors: Vec::new(), - server_port: 8091, system: String::from(""), + actors: Vec::new(), } } } impl Spawn { - pub fn add_actor(&mut self, actor: Box) -> &mut Spawn { - self.actors.push(actor); - self - } - - pub fn get_actors(&mut self) -> &mut Vec> { - &mut self.actors - } - - pub fn get_port(&mut self) -> u16 { - self.server_port - } - - pub fn get_system(&mut self) -> &mut String { - &mut self.system - } - pub fn new() -> Self { Default::default() } - pub fn port(&mut self, server_port: u16) -> &mut Spawn { - self.server_port = server_port; + pub fn create(&mut self, system_name: String) -> &mut Spawn { + self.system = system_name; self } - pub fn system(&mut self, system_name: String) -> &mut Spawn { - self.system = system_name; + pub fn with_actor(&mut self, actor: &mut ActorDefinition) -> &mut Spawn { + self.actors.push(actor.to_owned()); self } - pub async fn start(&mut self) -> Result<()> { - let server = HttpServer::new(move || { - //let actors: Vec<&Box> = self.get_actors(); + pub async fn start(&mut self) -> Result<(), rocket::Error> { + env_logger::init_from_env(env_logger::Env::new().default_filter_or("debug")); - //let actors_cell: Cell>> = Cell::new(self.get_actors()); + let figment = rocket::Config::figment().merge(("port", 8093)); + let mut handler: Handler = Handler::new(); + handler.add_actors(self.actors.as_mut()); - App::new() - .app_data(Data::new("")) - .wrap(middleware::Logger::default()) - .configure(Self::config) - }) - .bind(("127.0.0.1", self.get_port()))? - .run(); - - //future::join(server, another_func()).await; - server.await - } + let state = Arc::new(Mutex::new(handler)); - fn config(conf: &mut web::ServiceConfig) { - let scope = web::scope("/api/v1/actors").service(callback::v1::handle); + rocket::custom(figment) + .mount("/", routes![handle]) + .manage(state) + .ignite() + .await? + .launch() + .await?; - conf.service(scope); + Ok(()) } } diff --git a/spawn-rs/src/value.rs b/spawn-rs/src/value.rs index 12b3d2b..58e1228 100644 --- a/spawn-rs/src/value.rs +++ b/spawn-rs/src/value.rs @@ -29,8 +29,11 @@ impl Value { &self.state } - pub fn response(&mut self, response: Any) -> &mut Value { - self.response = response; + pub fn response(&mut self, message: &T) -> &mut Value + where + T: prost::Name, + { + self.response = Any::from_msg(message).unwrap(); self }