Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: dynamic upstream and routing for proxy #464

Open
georglauterbach opened this issue Nov 11, 2024 · 0 comments
Open

question: dynamic upstream and routing for proxy #464

georglauterbach opened this issue Nov 11, 2024 · 0 comments
Assignees

Comments

@georglauterbach
Copy link

georglauterbach commented Nov 11, 2024

What is the problem your feature solves, or the need it fulfills?

Given this code:

fn main() {
    let mut server =
        pingora::server::Server::new(Some(pingora::server::configuration::Opt::parse_args()))
            .unwrap();
    server.bootstrap();

    let mut proxy = pingora::proxy::http_proxy_service(&server.configuration, Gateway);
    proxy.add_tcp("0.0.0.0:3456");
    server.add_service(proxy);

    server.run_forever();
}

#[derive(Debug)]
pub struct Gateway;

#[async_trait::async_trait]
impl pingora::proxy::ProxyHttp for Gateway {
    type CTX = ();
    fn new_ctx(&self) -> Self::CTX {}

    async fn upstream_peer(
        &self,
        _session: &mut pingora::proxy::Session,
        _ctx: &mut Self::CTX,
    ) -> pingora::Result<Box<pingora::upstreams::peer::HttpPeer>> {
        let peer = Box::new(pingora::upstreams::peer::HttpPeer::new(
            ("127.0.0.1", 80),
            false,
            "".to_string(),
        ));
        Ok(peer)
    }
}

I'd simply like to know how I would best go about adding new upstreams and configuration dynamically (during run-time). I read in #250 (comment) that it should be possible already.

CC @eaufavor

@johnhurt johnhurt self-assigned this Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants