Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 17 19:13

    robjtede on master

    tweak migration document (compare)

  • Feb 17 08:12
    stanley355 commented #2650
  • Feb 17 01:07
    stanley355 commented #2650
  • Feb 16 14:10
    robjtede commented #2650
  • Feb 16 14:09
    robjtede labeled #2650
  • Feb 16 14:09
    robjtede closed #2650
  • Feb 16 14:09
    robjtede commented #2650
  • Feb 16 12:53
    stanley355 opened #2650
  • Feb 16 03:44

    github-actions[bot] on gh-pages

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

  • Feb 16 03:32

    github-actions[bot] on gh-pages

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

  • Feb 16 03:13

    robjtede on test-v0.1.0-beta.13

    (compare)

  • Feb 16 03:13

    robjtede on http-test-v3.0.0-beta.13

    (compare)

  • Feb 16 03:13

    robjtede on master

    prepare actix-http-test release… prepare actix-test release 0.1.… (compare)

  • Feb 16 03:13

    github-actions[bot] on gh-pages

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

  • Feb 16 03:11

    robjtede on actors-v4.0.0-beta.12

    (compare)

  • Feb 16 03:11

    robjtede on master

    prepare actix-web-actors releas… (compare)

  • Feb 16 03:10

    robjtede on awc-v3.0.0-beta.21

    (compare)

  • Feb 16 03:10

    robjtede on master

    prepare awc release 3.0.0-beta.… (compare)

  • Feb 16 03:07

    robjtede on http-v3.0.0-rc.3

    (compare)

  • Feb 16 03:07

    robjtede on master

    prepare actix-http release 3.0.… (compare)

Mehmet ERİBOL
@mehmeteribol_gitlab
hi. i am tring to implement a middleware example with beta-rc9 version.
fn call(&self, req: S::Request) -> Self::Future { TimeoutServiceResponse { fut: self.service.call(req), sleep: Sleep::new(clock::now() + self.timeout), } }
and it gives error: "fn call(&self, req: S::Request) -> Self::Future {
| ^^^^^^^ associated type Request not found"
asonix (he/they)
@asonix:matrix.asonix.dog
[m]
Request is no longer an associated type on the Service and Transform traits, it is a generic argument to the trait
so S::Request is no longer a valid type
Mehmet ERİBOL
@mehmeteribol_gitlab
I got this codes from api docs. Do i have to remove it?
asonix (he/they)
@asonix:matrix.asonix.dog
[m]
It looks like the documentation is not correct. https://docs.rs/actix-web/4.0.0-beta.9/actix_web/dev/trait.Transform.html in the example Service implementation, the second argument to the call method should be of type Req, not of type S::Request
Mehmet ERİBOL
@mehmeteribol_gitlab
thank you, error is gone
Yoric
@dotyoric:matrix.org
[m]
Hi
I'm trying to write code that uses both actix-web and matrix-rust-sdk.
(i.e. I'm writing a bot with a web API)
Unfortunately, both libs seem to want to take control on the main thread.
  1. Afaict, the future returned by HttpServer.run() only resolves when we shutdown the webserver.
  1. Afaict, it's the same thing for the matrix-rust-sdk.
  1. According to my experiments, it looks like HttpServer::run cannot be called from a tokio::task::spawn.
Am I missing something?
robjtede
@robjtede:matrix.org
[m]
easiest trick here is to launch actix-web server in a new std thread
Yoric
@dotyoric:matrix.org
[m]
Oh, that would work? I assumed that the #[actix_web::main] was doing some magic.
dotyoric:matrix.org @dotyoric:matrix.org will try that.
Yoric
@dotyoric:matrix.org
[m]
robjtede: Do I have to somehow spin some kind of executor on that thread?
robjtede
@robjtede:matrix.org
[m]
Yoric
@dotyoric:matrix.org
[m]
Otherwise, I won't be able to await HttpServer::run.
robjtede
@robjtede:matrix.org
[m]
std::thread::spawn(move || {
  actix_web::rt::System::new().block_on(async move {
     ...
  })
})
Yoric
@dotyoric:matrix.org
[m]
Note: it's System::new("some name").
robjtede
@robjtede:matrix.org
[m]
right, in v3, yes
Yoric
@dotyoric:matrix.org
[m]
Also, it works :) Thanks!
(now attempting to deploy a MVP)
quambene
@quambene

Consider an endpoint for post requests via post macro (https://docs.rs/actix-web/3.3.2/actix_web/attr.post.html). For example using #[post("/login")].

Is it possible to define the path elsewhere like const LOGIN: &str = "/login" and use it in the post macro? I would like to collect all endpoints at one place.

I couldn't make it work. I tried #[post(LOGIN)] and #[post("{}", LOGIN)] as well as #[post("{LOGIN}")] but without success.

Cheers

3 replies
robjtede
@robjtede:matrix.org
[m]
rkfox
@rkfox
Are wildcard routes supported? ie.
#[get("/files/*"
I'm not sure what happened; I thought this was working before. But now this wildcard route is not working.
rkfox
@rkfox
I was using one of the betas previously; maybe v4.0.0-beta.4 but I can't seem to get it working again. I think it broke after upgrading to beta.8.
1 reply
Stepan Kuzmin
@stepankuzmin

Hi everyone!

I'm getting thread panic in runtime after upgrading actix from 0.10 to either 0.11 or 0.12 with

thread 'main' panicked at '`spawn_local` called from outside of a `task::LocalSet`', /Users/stepan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.12.0/src/task/local.rs:305:18

The only change I've made to my code is that I've removed the name argument from the actix::System::new:

let sys = actix::System::new();

let db = SyncArbiter::start(3, move || DbActor(pool.clone()));
let coordinator: Addr<_> = CoordinatorActor::default().start();

HttpServer::new(move || {
    let state = create_state(db.clone(), coordinator.clone(), config.clone());

    let cors_middleware = Cors::default().allow_any_origin();

    App::new()
        .data(state)
        .wrap(cors_middleware)
        .wrap(middleware::NormalizePath::new(
            middleware::normalize::TrailingSlash::MergeOnly,
        ))
        .wrap(middleware::Logger::default())
        .wrap(middleware::Compress::default())
        .configure(router)
})
.bind(listen_addresses.clone())
.unwrap_or_else(|_| panic!("Can't bind to {}", listen_addresses))
.keep_alive(keep_alive)
.shutdown_timeout(0)
.workers(worker_processes)
.run();

sys.run()

My current dependencies are

actix = "0.12"
actix-cors = "0.5.4"
actix-rt = "1.1"
actix-web = "3.3.2"

What am I missing?

Stepan Kuzmin
@stepankuzmin

I got it

actix 0.12 depends on actix-rt 2 which is not compat with actix-rt 1

Namely this pattern would not work anymore.
let sys = System::new();
HttpServer::run();
Instead it should be changed to something like this.
System::new().block_on(some_future)

Izdihar
@tengkuizdihar:matrix.org
[m]
So, I'm using actix + diesel for one of my hobby project. What do you guys think about using block_on when using diesel?
5 replies
Given that I use web::block
Well thank you for the insight. I've seen some questions online being asked about this and they said that I'm going to use the same thread pool as actix and might block the process if there's enough load? That's how I remember it anyway.
2 replies
Izdihar
@tengkuizdihar:matrix.org
[m]
I guess I need to get a deeper understanding on how this block thing works, given I'm a bit blind on this topic
2 replies
robjtede
@robjtede:matrix.org
[m]
It's come to our attention that the MSRV for Actix Web v3 was recently increased by a dependency update: http v0.2.5. It would now be Rust 1.46. If you want to keep the old MSRV 1.42 it should be as easy as adding an exact dep in your Cargo.toml: http = "=0.2.4".
asonix (he/they)
@asonix:matrix.asonix.dog
[m]
I tried implemeting io-uring support in my image hosting api and it works
1 reply
i think it's a tiny bit slower than using tokio::fs::File but that's because i implemented AsyncRead, AsyncWrite, and AsyncSeek on a wrapper of tokio_uring::fs::File and reading and writing copies all the bytes around
so maybe if I reworked my program to play more directly to io-uring i could squeeze out some more performance
Maybe implementing Stream<Item = Bytes> on tokio_uring::fs::File could work, since you could read directly into a Vec<u8> which you can magic into a Bytes at little cost
fakeshadow
@fakeshadow
I observer dobule the throughput with high concurrent file streaming.
I tried with 12core and 2048 connections.
I also found some tips to optimize the performance on system side. Like make the memlock setting bigger. disable cpu mitigation. and use newest kernel release. Right now 5.15-rc could be the fastest for io-uring. I recall earlier some people claim to achieve a new peak of IOPS using it.
fakeshadow
@fakeshadow
BTW I have not tested it on regular hard drive but I believe the best use case for it is at least a decent nvme ssd.
Vince
@vlmutolo:matrix.org
[m]

Quick question: the actix docs for "shared mutable state" (here) suggest to use a Mutex from std::sync to make types thread-safe. This seems like it could be problematic since Mutex can block the current thread.

I don't know much about the internals of Actix. Is this just not a problem?

22 replies
gzp-crey
@gzp-crey
Is there some utility function to url (percent) encode/decode strings ? I'd not pull in another crate if actix_web has one already.
1 reply
Ashanti Mutinta
@AshantiMutinta
Quick question, I am doing some monitoring of my server which doesn't really have state. One thing I am finding is that my virtual memory usage is pretty high. I was wondering if anyone has some insight into this or has come across this in anyway? Using actix-web 4.0.0.beta
1 reply