pub fn init_worker<CT>(worker_config: WorkerConfig, client: CT) -> Worker
where
    CT: Into<AnyClient>,
{
    let as_enum = client.into();
    // TODO: Assert namespaces match
    let client = match as_enum {
        AnyClient::HighLevel(ac) => ac,
        AnyClient::LowLevel(ll) => {
            let client = Client::new(*ll, worker_config.namespace.clone());
            let retry_client = RetryClient::new(client, RetryConfig::default());
            Arc::new(retry_client)
        }
    };
    let c_opts = client.get_options().clone();
    if client.namespace() != worker_config.namespace {
        panic!("Passed in client is not bound to the same namespace as the worker");
    }
    let client_bag = Arc::new(WorkerClientBag::new(
        Box::new(client),
        worker_config.namespace.clone(),
    ));
    let sticky_q = sticky_q_name_for_worker(&c_opts.identity, &worker_config);
    let metrics = MetricsContext::top_level(worker_config.namespace.clone())
        .with_task_q(worker_config.task_queue.clone());
    Worker::new(worker_config, sticky_q, client_bag, metrics)
}
/// Initialize a worker bound to a task queue
Initialize a worker bound to a task queue
Initialize a worker bound to a task queue
pub fn init_worker<CT>(worker_config: WorkerConfig, client: CT) -> Worker
where
    CT: Into<AnyClient>,
{
    let as_enum = client.into();
    // TODO: Assert namespaces match
    let client = match as_enum {
        AnyClient::HighLevel(ac) => ac,
        AnyClient::LowLevel(ll) => {
            let client = Client::new(*ll, worker_config.namespace.clone());
            let retry_client = RetryClient::new(client, RetryConfig::default());
            Arc::new(retry_client)
        }
    };
    let c_opts = client.get_options().clone();
    if client.namespace() != worker_config.namespace {
        panic!("Passed in client is not bound to the same namespace as the worker");
    }
    let client_bag = Arc::new(WorkerClientBag::new(
        Box::new(client),
        worker_config.namespace.clone(),
    ));
    let sticky_q = sticky_q_name_for_worker(&c_opts.identity, &worker_config);
    let metrics = MetricsContext::top_level(worker_config.namespace.clone())
        .with_task_q(worker_config.task_queue.clone());
    Worker::new(worker_config, sticky_q, client_bag, metrics)
}
pub fn init_worker < CT > ( worker_config : WorkerConfig , client : CT ) -> Worker where CT : Into < AnyClient > , { let as_enum = client . into ( ) ; // TODO: Assert namespaces match let client = match as_enum { AnyClient :: HighLevel ( ac ) => ac , AnyClient :: LowLevel ( ll ) => { let client = Client :: new ( * ll , worker_config . namespace . clone ( ) ) ; let retry_client = RetryClient :: new ( client , RetryConfig :: default ( ) ) ; Arc :: new ( retry_client ) } } ; let c_opts = client . get_options ( ) . clone ( ) ; if client . namespace ( ) != worker_config . namespace { panic ! ( " " ) ; } let client_bag = Arc :: new ( WorkerClientBag :: new ( Box :: new ( client ) , worker_config . namespace . clone ( ) , ) ) ; let sticky_q = sticky_q_name_for_worker ( & c_opts . identity , & worker_config ) ; let metrics = MetricsContext :: top_level ( worker_config . namespace . clone ( ) ) . with_task_q ( worker_config . task_queue . clone ( ) ) ; Worker :: new ( worker_config , sticky_q , client_bag , metrics ) }
Initialize a worker bound to a task queue
Initialize a worker bound to a task queue
worker_config
WorkerConfig
client
CT
worker_config
WorkerConfig
client
CT