actix / actix/actix-web

Multiple services over multiple sockets example creates an incorrect AppConfig

Aperta
#3,180 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
24.8k
Fork
1.9k
Merge medio
23h 10m
PR unite (30g)
26

Descrizione

Per conversations on the discord, the most idiomatic way to spawn multiple services over multiple sockets is by following the current [actix-http example](https://github.com/actix/actix-web/blob/03456b8/actix-http/examples/actix-web.rs) using `actix_server::Server`.

This is preferred over the alternative of spawning more than one `HttpServer` as that results in each `HttpServer` spawning exclusive threads for themselves (e.g. 2 of them would spawn n*2 threads, where n is number of physical cores).

## Expected Behavior

## Current Behavior

However the example requires construction of an `AppConfig` whose only public constructor is its `Default`, which results in an incorrect configuration (server's hostname, address, and whether TLS is in use). This results in incorrect values for `HttRequest`'s `app_config`, `connection_info` and maybe `url_for` methods and even possibly other things?

## Possible Solution

Per @robjtede it's probable that this is a gap in the public interface. Either `AppConfig` needs an alternative constructor or possibly `actix_server::Server` or its builder could construct `AppConfig` from the values they have.

## Steps to Reproduce (for bugs)

## Context

## Your Environment

- Actix Web Version: 4.2

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.