Ejemplo n.º 1
0
void Shouter::start() {
    char buffer[4096];
    size_t read,ret;

    stop_requested=false;
    refresh_metadata();

    if (shout_open(shout) == SHOUTERR_SUCCESS) {
        printf("Connected to server...\n");
        while (!stop_requested) {

            if(refresh_metadata_requested) {
                refresh_metadata_requested=false;
                log(0,"Refreshing metadata.....");
                do_refresh_metadata();
            }

            read = source->get_data(buffer, 4096);

            if (read > 0) {
                ret = shout_send(shout, (unsigned char*)buffer, read);
                if (ret != SHOUTERR_SUCCESS) {
                    printf("DEBUG: Send error: %s\n", shout_get_error(shout));
                    break;
                }
            } else {
                break;
            }

            shout_sync(shout);
        }
    } else {
        printf("Error connecting: %s\n", shout_get_error(shout));
    }
}
Ejemplo n.º 2
0
void rt_kafka_cluster_t::router_loop() {
	topic_kafka_rpc_t rpc;

	while(!rpc_queue_.is_closed() && rpc_queue_.get(&rpc)) {
		try {
			if(!metadata_correct_ && std::chrono::system_clock::now() > next_allowed_refresh_) {
				refresh_metadata();
			}

			route_rpc(rpc);
		} catch(std::exception& e) {
			metadata_correct_ = false;
			rpc.promise.set_exception(std::current_exception());
		}
	}

	while(rpc_queue_.get(&rpc)) {
		rpc.promise.set_exception(std::runtime_error("rt_kafka_cluster_t is shutting down"));
	}
}