pub fn start(self) {
        let hosturl = self
            .config
            .hosturl()
            .ok_or_else(|| {
                error!("Failed to load service URL");
                "Failed to load service URL"
            })
            .unwrap();

        let addr = hosturl
            .parse::<SocketAddr>()
            .map_err(|err| {
                error!("Failed to parse SocketAddr: {:?}", err);
                err
            })
            .unwrap();

        let socket = UdpSocket::bind(&addr).unwrap();
        info!("Listening on: {}", addr);

        let mut buf = vec![0; 4096].into_boxed_slice();
        loop {
            if let Ok((size, peer)) = socket.recv_from(&mut buf) {
                if let Ok(query) = String::from_utf8(buf[0..size].to_vec()) {
                    let mut resp = match execute(
                        &query,
                        None,
                        &self.root_node,
                        &Variables::new(),
                        &self.context,
                    ) {
                        Ok((val, errs)) => serde_cbor::to_vec(&CborGQLResponse {
                            data: val,
                            errors: errs,
                        })
                        .unwrap(),
                        Err(e) => serde_cbor::to_vec(&CborGQLErrors { errors: e }).unwrap(),
                    };

                    if resp.len() > 64 * 1024 {
                        error!("Graphql Response too large");
                        resp = serde_cbor::to_vec(&CborGQLResponse {
                            data: juniper::Value::Null,
                            errors: vec![juniper::ExecutionError::at_origin(
                                juniper::FieldError::new(
                                    "CBOR Response too large",
                                    juniper::Value::Null,
                                ),
                            )],
                        })
                        .unwrap();
                    }

                    if let Err(e) = socket.send_to(&resp, &peer) {
                        error!("Failed to send udp response: {:?}", e);
                    };
                }
            }
        }
    }
/// Starts the service's GraphQL/UDP server. This function runs
/// without return.
///
/// # Panics
///
/// The UDP interface will panic if the ip address and port provided
/// cannot be bound (like if they are already in use), or if for some reason the socket fails
/// to receive a message.
Starts the service's GraphQL/UDP server. This function runs
without return.
Starts the service ' s GraphQL / UDP server . This function runs without return .
pub fn start(self) {
        let hosturl = self
            .config
            .hosturl()
            .ok_or_else(|| {
                error!("Failed to load service URL");
                "Failed to load service URL"
            })
            .unwrap();
        let addr = hosturl
            .parse::<SocketAddr>()
            .map_err(|err| {
                error!("Failed to parse SocketAddr: {:?}", err);
                err
            })
            .unwrap();
        let socket = UdpSocket::bind(&addr).unwrap();
        info!("Listening on: {}", addr);
        let mut buf = vec![0; 4096].into_boxed_slice();
        loop {
            if let Ok((size, peer)) = socket.recv_from(&mut buf) {
                if let Ok(query) = String::from_utf8(buf[0..size].to_vec()) {
                    let mut resp = match execute(
                        &query,
                        None,
                        &self.root_node,
                        &Variables::new(),
                        &self.context,
                    ) {
                        Ok((val, errs)) => serde_cbor::to_vec(&CborGQLResponse {
                            data: val,
                            errors: errs,
                        })
                        .unwrap(),
                        Err(e) => serde_cbor::to_vec(&CborGQLErrors { errors: e }).unwrap(),
                    };
                    if resp.len() > 64 * 1024 {
                        error!("Graphql Response too large");
                        resp = serde_cbor::to_vec(&CborGQLResponse {
                            data: juniper::Value::Null,
                            errors: vec![juniper::ExecutionError::at_origin(
                                juniper::FieldError::new(
                                    "CBOR Response too large",
                                    juniper::Value::Null,
                                ),
                            )],
                        })
                        .unwrap();
                    }
                    if let Err(e) = socket.send_to(&resp, &peer) {
                        error!("Failed to send udp response: {:?}", e);
                    };
                }
            }
        }
    }
pub fn start ( self ) { let hosturl = self . config . hosturl ( ) . ok_or_else ( | | { error ! ( " " ) ; " " } ) . unwrap ( ) ; let addr = hosturl . parse :: < SocketAddr > ( ) . map_err ( | err | { error ! ( " " err ) ; err } ) . unwrap ( ) ; let socket = UdpSocket :: bind ( & addr ) . unwrap ( ) ; info ! ( " " addr ) ; let mut buf = vec ! [ 0 4096 ] . into_boxed_slice ( ) ; loop { if let Ok ( ( size , peer ) ) = socket . recv_from ( & mut buf ) { if let Ok ( query ) = String :: from_utf8 ( buf [ 0 .. size ] . to_vec ( ) ) { let mut resp = match execute ( & query , None , & self . root_node , & Variables :: new ( ) , & self . context , ) { Ok ( ( val , errs ) ) => serde_cbor :: to_vec ( & CborGQLResponse { data : val , errors : errs , } ) . unwrap ( ) , Err ( e ) => serde_cbor :: to_vec ( & CborGQLErrors { errors : e } ) . unwrap ( ) , } ; if resp . len ( ) > 64 * 1024 { error ! ( " " ) ; resp = serde_cbor :: to_vec ( & CborGQLResponse { data : juniper :: Value :: Null , errors : vec ! [ juniper ExecutionError at_origin ( juniper FieldError new ( " " juniper Value Null ) ) ] , } ) . unwrap ( ) ; } if let Err ( e ) = socket . send_to ( & resp , & peer ) { error ! ( " " e ) ; } ; } } } }
Starts the service's GraphQL/UDP server.
Starts the service ' s GraphQL / UDP server .
self
self
panics
The UDP interface will panic if the ip address and port provided
cannot be bound (like if they are already in use), or if for some reason the socket fails
to receive a message.
The UDP interface will panic if the ip address and port provided cannot be bound ( like if they are already in use ) or if for some reason the socket fails to receive a message .