Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 23:53
    jplatte commented #1721
  • 23:29
    robjtede commented #1721
  • 23:24
    robjtede commented #1721
  • 20:17

    github-actions[bot] on gh-pages

    Deploying to gh-pages from @ 0… (compare)

  • 20:15
    robjtede labeled #1749
  • 20:15
    robjtede labeled #1749
  • 20:15
    robjtede labeled #1752
  • 20:15
    robjtede labeled #1752
  • 20:15

    robjtede on master

    use idenity encoding on client … (compare)

  • 20:15
    robjtede closed #1737
  • 20:15
    robjtede closed #1731
  • 19:34
    codecov-io commented #1737
  • 19:34

    github-actions[bot] on gh-pages

    Deploying to gh-pages from @ 4… (compare)

  • 19:31
    robjtede synchronize #1737
  • 19:31

    robjtede on master

    Re-export bytes::Buf and bytes:… (compare)

  • 19:31
    robjtede closed #1750
  • 19:28
    codecov-io commented #1750
  • 19:25
    codecov-io commented #1750
  • 19:01
    robjtede synchronize #1737
  • 18:59
    robjtede edited #1750
KOKOU AFIDEGNON
@afidegnum
@robjtede please, i am trying to rewrite the function in line https://github.com/afidegnum/usersman/blob/master/src/auth/password_handler.rs#L203 so i can use rust_postgres, https://github.com/afidegnum/usersman/blob/master/src/auth/password_handler.rs#L143
but i'm facing some difficulties.
i'm stuck in how to incorporate the client.query in ln: 155 so i will be able test the result and perform the insert operation. I don't know if i'm clear with the question.
Bernard Labno
@blabno
@robjtede Thank you for 0.10.0 release. I think a bit more has changed than described in https://github.com/actix/actix/releases/tag/v0.10.0
Rob Ede
@robjtede
Okay @blabno feel free to open a PR with the additions if you think they will help folks migrate.
Bernard Labno
@blabno

I want to call async function on my actor from handle function.

impl MyActor {
    async fn do_something_asynchronosuly(&self) { }
}
fn handle(&mut self, msg: Something, ctx: &mut Self::Context) -> Self::Result {
    self.do_something_asynchronosuly().await
}

I'm getting this error

self has an anonymous lifetime '_ but it needs to satisfy a 'static lifetime requirement

How to solve this in 0.9.0?

fakeshadow
@fakeshadow
It can't be. This is one limitation(or design choice) of actix. The futures you return in a handle method must be bound to static lifetime which mean the future either borrow nothing from it's parent or borrow something with 'static lifetime(stuff like static variables and thread_local static variables).
Bernard Labno
@blabno
So all the methods of actor must be synchronous if they are to be called from handle?
fakeshadow
@fakeshadow
If it borrows anything then yes. no matter if it's your actor, your message or your context. You can use other ways to wait for a future and access your actor states after that
But not in an async block
Bernard Labno
@blabno
I guess I have to take out whatever I need from the actor inside handle and do this
fn handle(&mut self, msg: Something, ctx: &mut Self::Context) -> Self::Result {
        async {}
        .into_actor(self)
        .spawn(ctx);
    }
fakeshadow
@fakeshadow
yes.as long as the async block owns all the variables it uses then you are good.
For example you can wrap your actor state in an Rc and clone it then move in the async block
This way you would be able to have a immutable pointer to your actor state in the async block while satisfy the static lifetime
Bernard Labno
@blabno
Thank you
Dag
@scav
I need to get a copy of the request body as it enters my service, right now I am trying to fetch it from in a impl FromRequest trying to create a copy of the body from fn from_request(r: &HttpRequest, p: &mut dev::Payload) -> Self::Future dev::Payload. I have to admit I have no idea how I am supposed to do this, or if there is any other better way of getting ahold of the request body before processing the request (the body contains some data I need to verify the request signature).
15 replies
Zihua Wu
@lucifer1004
How to serve files with UTF-8 contents (e.g., Chinese characters) with actix-files?
5 replies
Aspect1337
@Aspect1337
Hello. Is there anyone who has a working code rep with Actix-web + React?
2 replies
Xu Desheng
@xudesheng
It seems like actix-mqtt becomes ntex-mqtt now, is there any way to let ntex-rt and actix-rt work together?
5 replies
Pankaj Jangid
@jangid
Just noticed - actix3 is out. Thanks a lot team. Great effort.
Elang89
@Elang89
Got a question, though not necessarily about actix but it relates to it somewhat. When is it a good reason to use actors? Like, what is a good use case for actix and actors in general?
3 replies
Tomas Ostasevicius
@to266
Hi there, is there some way to inject state into the Axtix::web App? I'd like to be able to mock a struct that implements a trait (which wraps an external API). The first hope was to have some &dyn MyTrait in the app_data, but since that matches from the HashMap based on TypeId, inserting a particular type and extracting with web::Data<&dyn MyTrait> does not actually work. So... any suggestions?
10 replies
Dan
@dansgithubuser
Is there an easy way to get my logger middleware to show request and response bodies?
Or a hard way I suppose, but... no harder than just writing logging into my handlers...
3 replies
Simon Paitrault
@Freyskeyd

Hello!

I'm trying to build an app where I've an API (with actix-web) and another domain runtime (with actix actors) that deal with database and other stuff. I was wondering what was the best way to communicate between those two entities and if there is some example around that kind of project?

8 replies
matrixbot
@matrixbot
tml hi, is there any benefit to the sync actor ("executor") pattern, as in the old version of the docs over just using web::block as in the new docs?
1 reply
matrixbot
@matrixbot

tml > <@robjtede:matrix.org> @tml if you're expecting to use other actors i guess. web::block has been the recommended method for DB calls since v2 and the docs now reflec that.

Hm, is web::block incompatible with actors?

matrixbot
@matrixbot

tml > <@tmladek:matrix.org> Hm, is web::block incompatible with actors?

As in, can I call web::block inside of actors and vice-versa?

matrixbot
@matrixbot

robjtede > <@tmladek:matrix.org> As in, can I call web::block inside of actors and vice-versa?

Sure you can do that but theres kinda no point doing both and just requires more passing around of channel senders.

Bernard Labno
@blabno

I've got

#[derive(Message, Debug)]
#[rtype(result = "Vec<String>")]
pub struct GetItems;

impl Handler<GetItems> for SomeActor {
    type Result = Vec<String>;

    fn handle(&mut self, msg: GetItems, _ctx: &mut Self::Context) -> Self::Result {
        println!("Got {:?}", msg);
        vec![]
    }
}

which gives me

the trait bound Vec<std::string::String>: MessageResponse<SomeActor, GetItems> is not satisfied.

I've seen example where Result type was Result<Vec<String>> but I don't get why that works.

13 replies
matt-vib
@matt-vib
This message was deleted
Kevin Choubacha
@kbacha
Hi! I'm trying to setup an actix-web server but also want to daemonize the main process. I have it set up using the daemonize crate (https://docs.rs/daemonize/0.4.1/daemonize/) but I'm getting some errors when the server actually boots:
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Int err: Bad file descriptor (os error 9)
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Hup err: Bad file descriptor (os error 9)
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Term err: Bad file descriptor (os error 9)
[2020-09-17T19:57:37Z ERROR actix_server::signals] Can not initialize stream handler for Quit err: Bad file descriptor (os error 9)
Kevin Choubacha
@kbacha
I think I need to daemonize before the actix-rt starts so that the daemonizing doesn't close any file descriptor listeners... But I can't find examples of setting that up.
Kevin Choubacha
@kbacha
Nothing I've tried works to properly boot the runtime other than the macro...
Alan Briolat
@alanbriolat
Am I crazy if I want to use actix directly as an actor framework? I'm really struggling to understand the boundary between async/await and message-passing. Examples make use of addr.send().await inside an async fn main(), but are less clear on how to do the same thing within a Handler<T>::handle(), which isn't an async fn...
Alan Briolat
@alanbriolat
For example, I have an actor that needs to establish a TCP connection once the actor is already started. The documentation for actix::actors::resolver only shows use from async functions outside of an actor, so what pattern should I be using to use that from within a message handler?
19 replies
NielDuysters
@NielDuysters
I can't find anywhere in the Actix-Cors documentation on how to allow Access-Control-Allow-Origin so I can allow GET/POST requests to my Rust-code from other domains.
1 reply
Alex
@awulkan
Maybe you already know this, but the Actix benchmarks are gone from TechEmpower.
12 replies
ghostff
@Ghostff
Why does actix.rs(https://actix.rs/docs/databases/) encourage using Diesel instead of async_pg?
2 replies
Paul Kassianik
@paulkass
Hey guys, wondering if there's any documentation to handle file uploads in Post requests?
2 replies
zero-systems
@zero-systems
How do I get current tokio/actix-rt loop inside HttpServer::new(move || App::new()?
3 replies
For each worker
I need to do some async actions while creating .data
Alan Briolat
@alanbriolat
Is there an upperbound on what a sensible number of actors is, either in terms of performance or just "you're doing it wrong"?
10 replies
Alan Briolat
@alanbriolat
I'm playing around with trying to build a BitTorrent client, which is obviously a pretty IO-bound use case. My thoughts so far are that the logical division of responsibilities, and therefore actors, is a single Session actor (which is the entry point for the frontend communicating with the core), a Torrent actor per loaded torrent (potentially thousands), a Peer actor per known peer (tens of thousands, only a few hundred of which would have active connections at any one time), and some mechanism to globally limit simultaneous connection count and file handle count.
Does this sound sensible, or like I should be considering pooling things into fewer actors, or not even using the actor model at all?
WiredSharp
@WiredSharp
Hi all, as a Rust Newbie, i tried to build a web site with actix-web. I wanted to process default url to index.html. So i decided to write a middleware to do the job. To modify the Request uri, i followed what was done in Normalize middleware but it looks to me a lot of code to change the path of the request, isn't there any simpler way to do this?
2 replies
Kevin Hoffman
@autodidaddict
I'm sure this has been asked a million times... I've got a synchronous function (mandatory, it's an FFI callback) that needs to make a call into the actor system, await the result, and then return the result. I've tried all forms of "block_on" that I can think of and none of them work. What's the right way to "de-async" a call to an actor?
3 replies
Bernard Labno
@blabno
expected struct Box, found struct Pin