Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 03:15

    github-actions[bot] on gh-pages

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

  • 03:12

    JohnTitor on master

    Remove CoC on actix-http as dup… (compare)

  • 03:11

    github-actions[bot] on gh-pages

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

  • 03:09

    github-actions[bot] on gh-pages

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

  • 03:09

    JohnTitor on master

    Update CoC contact information (compare)

  • 03:07

    JohnTitor on master

    Update CoC contact information (compare)

  • 02:42

    github-actions[bot] on gh-pages

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

  • 02:39

    robjtede on master

    fix deps.rs badge (compare)

  • Oct 30 20:35
    codecov-io commented #1767
  • Oct 30 20:33
    codecov-io commented #1767
  • Oct 30 20:31
    codecov-io commented #1767
  • Oct 30 20:31
    codecov-io commented #1767
  • Oct 30 20:19
    fakeshadow closed #380
  • Oct 30 20:19
    fakeshadow commented #380
  • Oct 30 20:13
    Sebmaster commented #1767
  • Oct 30 20:12
    Sebmaster synchronize #1767
  • Oct 30 20:12
    neilyoung commented #1766
  • Oct 30 20:12
    Sebmaster synchronize #1767
  • Oct 30 20:11
    neilyoung commented #198
  • Oct 30 20:11
    robjtede commented #1766
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
Bernard Labno
@blabno
I've noticed that for ResponseFuture the Box::pin works, but for ResponseActFuture the Box::new is needed instead
17 replies
Bernard Labno
@blabno
btw. I am looking for someone to review ~1k lines of my actix code, I'm willing to pay for the job.
Bernard Labno
@blabno
Is it possible to convert ActorFuture to Future?
7 replies
Brian Victor
@brianhv
are there any reasonably mature solutions for (customer) authentication and identity management? basically looking to fill the role that django auth does, with login/registration/password reset/etc. should I be looking at something like AWS Cognito with OIDC?
Cris Liao
@clia
SSE long-polling connection server using Actix-web 3.0.2, while the clients use Java & okhttp lib, the server can support concurrent connections more than 400K; but when the clients use C++ & libcurl, when concurrent connections add up to 130K, the server will hangs on and logging:
"Service 0.0.0.0:443 is unavailable"
Accepting connections on 0.0.0.0:443 has been resumed
Anybody knows where the problem is?
ghostff
@Ghostff

Hi guys, I have this struct (diesel):

#[table_name = "users"]
#[derive(Insertable, Debug)]
pub struct NewUser<'a> {
    pub first_name: &'a str,
    pub last_name: &'a str,
}

let m = NewUser {
    first_name: "Foo",
    last_name: "Bar",
};

But am wondering why, I can do this:

let user: User = diesel::insert_into(...).values(&m).get_result(conn).expect(...);

But not this:

impl<'a> NewUser<'a> {
    pub fn create( & self, conn: &PgConnection) -> self::User {
        diesel::insert_into(...).values(self).get_result(conn).expect(...)
    }
}

m.create(conn);
1 reply
Tom CHEN
@surfingtomchen
Hi guys, is there any comprehensive example of actix-net? I'm quite new for the rust and seeking help to use actix-net framework to build my tcp server. TIA.
6 replies
Geometrically
@Geometrically
Hey, is there any examples/projects which use Auth0 for authentication?
1 reply
KOKOU AFIDEGNON
@afidegnum
hi, how do i extract data from web::data pool ?
1 reply
Geometrically
@Geometrically
How can I pass data from a middleware to a route?
1 reply
junefar
@junefar
Hi, How do I stop an actor with internal loops,sending a message doesn't work.
For example ,I use amiquip with actor, I can't stop it.
        for (_i, message) in consumer.receiver().iter().enumerate() {
            match message {
                ConsumerMessage::Delivery(delivery) => {
                    let msg = delivery.body.clone();
                    let foo = String::from_utf8(msg).unwrap();
                    let data = foo.to_string();
                    let k: Value = serde_json::from_str(&data).unwrap();
                    ctx.stop(); // doesn't work
                }
                other => {
                    println!("Consumer ended: {:?}", other);
                    break;
                }
            }
        }
33 replies
Pankaj Jangid
@jangid
/quit
Jonathan
@MonliH

Hi, how can I have resolve like functionality with actix-web? I want to get the server to send the www/build/index.html file if the file requested isn't in www/build. This code doesn't work:

#[get("/*")]
async fn home(_req: HttpRequest) -> io::Result<NamedFile> {
    Ok(NamedFile::open("www/build/index.html")?)
}

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new()
            .service(Files::new("/*", "www/build/"))
            .service(home)
    })
    .bind("127.0.0.1:8080")?
        .run()
        .await
}

The above code just tries to get the file from www/build, but then returns a 404 instead of trying the home service. Is there an easy way I can "chain" these?

Jonathan
@MonliH
Actually nevermind, I'm not sure why I didn't take a look at the API docs. It's pretty clear there;.default_handler(web::route().to(home))) did the job for me
dave-a-hawkins
@dave-a-hawkins
Hey ya'll! I'm using actix-web = "3" and actix-multipart = "0.3" and getting some weird behavior trying to upload a file - I can only seem to get the file name out of the payload.
dave-a-hawkins
@dave-a-hawkins

pub async fn test2(
mut payload: Multipart,
) -> Result<String, Error> {

let mut response_details: Vec<String> = vec![];
let mut result = String::from("");

while let Some(item) = payload.next().await {
    let mut field = item?;
    let mut myFileStream: Vec<u8> = vec![];


    // Field in turn is stream of *Bytes* object
    while let Some(chunk) = field.next().await {
        let mut data = chunk.unwrap().to_vec();
        myFileStream.append(&mut data);
    }

    println!("{}",
        format!("{:?}", myFileStream)
    );
}

}

myFileStream ends up only containing the name of the source file from the client.
49 replies
hakan-geijer
@hakan-geijer
Hi. I'm using actix-web 3 and actix-web-actors 3 and I have questions about websockets that both reply to incoming messages and pull from (for example) an AMQP queue. I'm trying to figure out what pattern works for this. I'm guessing it needs to be something like using ws::start_with_addr and passing the addr to a thread::spawn with an infinite loop that keeps sending to the WS actor until it gets an error. I don't see another clear way to do this. Anyone have suggestions?
16 replies
K0R0VA
@K0R0VA

Hello, i wanna make some function like this. Can you give me advice?

pub struct AppState {
pub db : Addr<PgActor>,
}

fn GetResponce<'de, I, F>(state : web::Data<AppState>, input : web::Json<I>, foo : F ) -> impl Future
where I : Deserialize<'de>,
F : Fn(Data<AppState>, Json<I>) -> Result<HttpResponse, Error> {
web::block ( move || foo (state, input))
}

mtkastner
@mkastner

Is there any documentation available on how to deploy an actix application on FreeBSD. Maybe with examples for rc.d scripts, etc. I find a lot of examples of how to deploy to docker containers or on heroku but I haven't found anything on plain old self hosting (yeah, redhat, that's right I'm a greybeard).

If anyone could point me to some docs or examples, that'd be awesome.