Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 19:57
    rohitjoshi commented #1191
  • 19:56
    rohitjoshi commented #1191
  • 19:34
    fafhrd91 commented #1191
  • 19:14
    rohitjoshi edited #1191
  • 19:14
    rohitjoshi opened #1191
  • 17:37
    fafhrd91 closed #1185
  • 17:37
    fafhrd91 commented #1185
  • 17:36
    fafhrd91 closed #1181
  • 17:36
    fafhrd91 commented #1181
  • 17:35

    fafhrd91 on master

    upgrade to tokio 0.2 (compare)

  • 06:45
    robo-corg commented #1190
  • 02:34
    dowlandaiello synchronize #35
  • 02:31
    dowlandaiello synchronize #35
  • 02:20
    dowlandaiello opened #35
  • 00:29
    cheolgyu commented #1136
  • Dec 04 22:48
    glademiller commented #298
  • Dec 04 22:10
    bitemyapp commented #1190
  • Dec 04 22:07
    bitemyapp commented #1190
  • Dec 04 22:02
    bitemyapp commented #1190
  • Dec 04 22:02
    bitemyapp commented #1190
Oron Sharabi
@oronsh
@fafhrd91 which ability the tokio team have removed that actix cant use it now? very interesting and sad
Folyd
@Folyd
@fafhrd91 I just wonder it's possible to use url_for function without an HttpRequest? For example, a macro url_for!() can do the same thing.
Matt Doughty
@m-doughty

Hi, probably a dumb question but I'm trying to get a good understanding. I roughly followed the example here: https://docs.rs/awc/0.3.0-alpha.1/awc/

I'm getting ^ the trait std::future::Future is not implemented for awc::sender::SendClientRequest.

What am I doing wrong?
Nikolay Kim
@fafhrd91
It is hard to tell, but example from api doc is being tested on each commit
Carlos Malanche Flores
@Malanche
@fafhrd91 Hmmm... But that seems to imply I need one ws client to send messages, and one actix Actor to receive them (so having two websocket connections, even though the websockets protocol is bidirectional) per rust binary to create the connection. Can't I connect directly two actix Actors using the ws::WebsocketContext?
Abid Omar
@omarabid
@fafhrd91 I'm using actix-files to deploy a static website. Is it possible to bundle it within the executable (with something like include_str!?)
ousado
@ousado
@omarabid sure
Abid Omar
@omarabid
any examples of doing that?
ousado
@ousado
I don't have any, but there's no reason why it shouldn't work.
Abid Omar
@omarabid
@ousado I know it "makes sense" but the thing is, there are lots of file (html/js/images). So I want something/some solution which bundle all of these and then actix-web?actix-files uses them
ousado
@ousado
@omarabid You could bundle resources for each page in a JSON structure (or maybe a format that can handle binary data, so you don't have to encode it), and have another structure for the website.
If you're looking for a ready to go solution, I don't know whether that exists
Matt Joiner
@anacrolix
hi all. how would i parse repeated query params, say of the form ?term=a&term=b&term=c. I tried a naive Query<struct{terms:Vec<String}> but it doesn't like that.
Aaron Housh
@Dispersia
Does anyone have trouble compiling off master? The build is succeeding in CI, but I get no 'BoxServiceFactory' in 'boxed' under actix_service::boxed
targeting 2.0.0-alpha.1 is fine, however.
Augusto C├ęsar Dias
@augustocdias
@anacrolix the crate that actix uses for parsing params doesn't support this use case
check for this crate instead
serde_qs = {version = "0.5.1", features=["actix"]}
Matthew Pocock
@drdozer
I just mapped over a 15k element vector and ran an actic awc client for each value, and killed the server ;) I really want instead to set up a resource that throttles the number of "in progress" requests to some maximum number. I guess a semaphore-like thing? Is there example code for that which I can learn from?
Matthew Pocock
@drdozer
I was looking at std::sync, but that all seems to block threads -- I was thinking there must be a solution within actix where it instead suspends the current future, and lets the thread get on with other stuff
Chris Lucas
@cjlucas
If I have an actor struct A { b: Addr<B> } and an actor struct B { recipient: Recipient<SomeMsg> } where the recipient is actually A, are the references between these two actors strong? In other words, If I have struct C { a: Addr<A> } that gets dropped, would the cyclical reference prevent A and B from shutting down?
Chris Lucas
@cjlucas
Or maybe a simpler example, since maybe my understanding of how actors get dropped is off. If I have an actor struct A { b: Addr<B> } which holds the only address to B, if A is stopped will B automatically stop?
ousado
@ousado
@drdozer sounds like you want to use a stream + buffered method
Nish Tahir
@nishtahir
is there a good example project available for actix-web 2.0.0?
i'm having trouble getting #[actix_rt::main] to resolve
Jack
@jh0l
how do you make actix CookieIdentityPolicy cookies persistent? there's no way to set the expires field of the underlying cookie
the cookie value is also removed on browser refresh regardless so setting the expires field doesn't seem to matter anyway
ousado
@ousado
What's the recommended way to interact with the filesystem in the upcoming actix 2.0?
Jack
@jh0l
it's okay, you can set the expires field of the identity cookie or make it permanent with this hack I eventually figured out
            .wrap_fn(|req, srv| {
                srv.call(req).map(|mut res: ServiceResponse| {
                    for mut res_cookie in res.response_mut().cookies() {
                        if res_cookie.name().eq_ignore_ascii_case("auth") {
                            res_cookie.make_permanent();
                        }
                    }
                    res
                })
            })
identity cookie can now be persistent across browser refreshes
Nikolay Kim
@fafhrd91
maybe actix-identity should be fixed?
yuluyi
@yuluyi

Hi I'm trying to implement a blanket implementation for all actors that can handle a specified message.
like this

use actix::prelude::*;


pub mod messages {
    use actix::prelude::*;
    pub enum TCCMessage<T: 'static> {
        Try(T),
        Confirm(T),
        Cancel(T)
    }

    impl <T> Message for TCCMessage<T> {
        type Result = Result<(), crate::errors::TCCError>;
    }
}



pub trait TCCActor {}

impl<A> TCCActor for A 
    where A: Handler<messages::TCCMessage<dyn std::any::Any + Sized>, Context = Context<A>,  Result = Result<(), crate::errors::TCCError>> + Actor
    {}

so that i can do

pub struct TCCCoodinatorActor {
    actors: Vec<Addr<dyn TCCActor>>
}

but the compiler complains about messages::TCCMessage<dyn std::any::Any + Sized + 'static> with "only auto traits can be used as additional traits in a trait object". Is there any walkaround?

qthree
@qthree
@fafhrd91 Hello, can you update actix-files, please?
 Compiling actix-files v0.2.0-alpha.1
error[E0432]: unresolved imports `actix_service::boxed::BoxedNewService`, `actix_service::boxed::BoxedService`
  --> D:\rust\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-files-0.2.0-alpha.1\src/lib.rs:15:34
   |
15 | use actix_service::boxed::{self, BoxedNewService, BoxedService};
   |                                  ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^ no `BoxedService` in `boxed`
   |                                  |
   |                                  no `BoxedNewService` in `boxed`
help: a similar name exists in the module
   |
15 | use actix_service::boxed::{self, BoxService, BoxedService};
   |                                  ^^^^^^^^^^
help: a similar name exists in the module
   |
15 | use actix_service::boxed::{self, BoxedNewService, BoxService};
   |                                                   ^^^^^^^^^^

error[E0053]: method `new_service` has an incompatible type for trait
   --> D:\rust\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-files-0.2.0-alpha.1\src/lib.rs:418:5
    |
418 |     fn new_service(&self, _: &()) -> Self::Future {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found &()
    |
    = note: expected type `fn(&Files, ()) -> std::pin::Pin<std::boxed::Box<(dyn core::future::future::Future<Output = std::result::Result<FilesService, ()>> + 'static)>>`
               found type `fn(&Files, &()) -> std::pin::Pin<std::boxed::Box<(dyn core::future::future::Future<Output = std::result::Result<FilesService, ()>> + 'static)>>`

error[E0308]: mismatched types
   --> D:\rust\.cargo\registry\src\github.com-1ecc6299db9ec823\actix-files-0.2.0-alpha.1\src/lib.rs:100:17
    |
100 | /                 web::block(move || {
101 | |                     let max_bytes: usize;
102 | |                     max_bytes = cmp::min(size.saturating_sub(counter), 65_536) as usize;
103 | |                     let mut buf = Vec::with_capacity(max_bytes);
...   |
111 | |                 })
112 | |                 .boxed_local(),
    | |______________________________^ expected enum `std::result::Result`, found tuple
    |
    = note: expected type `std::pin::Pin<std::boxed::Box<dyn core::future::future::Future<Output = std::result::Result<std::result::Result<(std::fs::File, bytes::bytes::Bytes), std::io::Error>, futures_channel::oneshot::Canceled>>>>`
               found type `std::pin::Pin<std::boxed::Box<dyn core::future::future::Future<Output = std::result::Result<(std::fs::File, bytes::bytes::Bytes), actix_threadpool::BlockingError<_>>>>>`

error: aborting due to 3 previous errors
Kirill Bulatov
@SomeoneToIgnore
^
I'm experiencing similar errors with the actix-utils:
   Compiling actix-utils v0.5.0-alpha1
error[E0053]: method `new_service` has an incompatible type for trait
  --> /Users/someonetoignore/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-0.5.0-alpha1/src/either.rs:95:5
   |
95 |     fn new_service(&self, cfg: &A::Config) -> Self::Future {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found reference
   |
   = note: expected type `fn(&either::Either<A, B>, <A as actix_service::ServiceFactory>::Config) -> either::EitherNewService<A, B>`
              found type `fn(&either::Either<A, B>, &<A as actix_service::ServiceFactory>::Config) -> either::EitherNewService<A, B>`
   = note: consider constraining the associated type `<A as actix_service::ServiceFactory>::Config` to `&<A as actix_service::ServiceFactory>::Config` or calling a method that returns `<A as actix_service::ServiceFactory>::Config`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

error[E0053]: method `new_service` has an incompatible type for trait
  --> /Users/someonetoignore/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-0.5.0-alpha1/src/keepalive.rs:61:5
   |
61 |     fn new_service(&self, _: &()) -> Self::Future {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found &()
   |
   = note: expected type `fn(&keepalive::KeepAlive<R, E, F>, ()) -> futures_util::future::ready::Ready<std::result::Result<keepalive::KeepAliveService<R, E, F>, std::convert::Infallible>>`
              found type `fn(&keepalive::KeepAlive<R, E, F>, &()) -> futures_util::future::ready::Ready<std::result::Result<keepalive::KeepAliveService<R, E, F>, std::convert::Infallible>>`

error[E0053]: method `new_service` has an incompatible type for trait
  --> /Users/someonetoignore/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-0.5.0-alpha1/src/time.rs:54:5
   |
54 |     fn new_service(&self, _: &()) -> Self::Future {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found &()
   |
   = note: expected type `fn(&time::LowResTime, ()) -> futures_util::future::ready::Ready<std::result::Result<time::LowResTimeService, std::convert::Infallible>>`
              found type `fn(&time::LowResTime, &()) -> futures_util::future::ready::Ready<std::result::Result<time::LowResTimeService, std::convert::Infallible>>`

error[E0308]: mismatched types
  --> /Users/someonetoignore/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-0.5.0-alpha1/src/either.rs:99:45
   |
99 |             left_fut: self.left.new_service(cfg),
   |                                             ^^^ expected associated type, found reference
   |
   = note: expected type `<A as actix_service::ServiceFactory>::Config`
              found type `&<A as actix_service::ServiceFactory>::Config`
   = note: consider constraining the associated type `<A as actix_service::ServiceFactory>::Config` to `&<A as actix_service::ServiceFactory>::Config` or calling a method that returns `<A as actix_service::ServiceFactory>::Config`
   = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

error[E0308]: mismatched types
   --> /Users/someonetoignore/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-utils-0.5.0-alpha1/src/either.rs:100:47
    |
100 |             right_fut: self.right.new_service(cfg),
    |                                               ^^^ expected associated type, found reference
    |
    = note: expected type `<A as actix_service::ServiceFactory>::Config`
               found type `&<A as actix_service::ServiceFactory>::Config`
    = note: consider constraining the associated type `<A as actix_service::ServiceFactory>::Config` to `&<A as actix_service::ServiceFactory>::Config` or calling a method that returns `<A as actix_service::ServiceFactory>::Config`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html

error: aborting due to 5 previous errors
Nikolay Kim
@fafhrd91
released
qthree
@qthree
Thanks!
Kirill Bulatov
@SomeoneToIgnore
Hi @fafhrd91 , I think my error is caused by the actix-multipart of version 0.2.0-alpha1 is using actix-utils of version 0.5.0-alpha1
I see that the actix-multipart master branch contains newer actix-utils, so sounds like another actix-multipart release would be enought to fix the issue.
Felipe Passos
@SharksT
Hello
i'm trying to pass a json with a list that has a list
but i'm getting this error :
'called Result::unwrap() on an Err value: Error("expected , or ]", line: 1, column: 64)'
With only 1 element in the second list work fine
Kirill Bulatov
@SomeoneToIgnore
Thank you for ther release.
Carman Babin
@babinc

Hello. I have been working with Actix for about a week now. From what I understand one arbiter is equal to one thread and one event loop. But with my current code that I am working with, when one arbiter is running a long executing function, it is blocking the other arbiter. I have an example of this behavior in the following github.

https://github.com/babinc/actix_testing

From the github example the AppActor is inside an AppArbiter. When the long_executing_stuff function from the AppActor is called the UiArbiter and UiActor is blocked. I was hoping that the UiActor and Arbiter would keep executing. Is there an easy way to get the functionality that I am desiring? In the real application that I am working with the UiArbiter is running tui-rs.

Thank you

Nikolay Kim
@fafhrd91
You can use Sync actor, or any kind of threadpool
Carman Babin
@babinc
@fafhrd91 Thank you for the feedback. Sync actor doesn't really give me the results I am looking for. I end up with an AppActor for each thread that I specify with only one of them containing the value that I set.
stoically
@stoically
@babinc what's blocking in your example is the fact that your SetValue message lets the AppArbiter thread sleep, and hence the GetValue send from the UiArbiter awaits (blocks) until the AppArbiter resumes
trying to GetValue something from a thread that's working (or sleeping) in a non-blocking way isn't going to work. you'd need something in the middle that holds the value where you can ask for it from the UI and update it from the blocking thread once that's done
Carman Babin
@babinc
@stoically thank you for the reply. I have few ideas to try.
gliderkite
@gliderkite
Hi all, I'm trying to send an HTTP request with multipart, where the content is a file compressed with gzip. I'm using as an example the actix server as defined here https://github.com/actix/examples/blob/master/multipart/src/main.rs, and the curl request that I use (after gzip example.txt -> example.txt.gz) is curl -X POST -H "Content-Type: multipart/related" -H "Content-Encoding: gzip" --form "data=@example.txt.gz" http://localhost:8080 (where I set the "Content-Encoding" header). According to the documentation I found here https://actix.rs/docs/request/, actix should automatically decompress the payload according to the header value. But it doesn't seem to work as the uploaded file is still gzipped. Does this decoding apply to multipart fields? How can I decode my multipart?