def consumer_entry(): cmd_args = parse_arguments() worker_type = cmd_args.worker_type assert worker_type in WORKER_CLASSES, \ 'Unsupported worker type: `%s`' % worker_type worker_cls = WORKER_CLASSES[worker_type] worker_cls.patch() consumer = load_entry_point(cmd_args.entry_point) assert inspect.isclass(consumer), 'consumer must be a class' from arkham.consumer.consumer import ArkhamConsumer, ArkhamConsumerRunner assert issubclass(consumer, ArkhamConsumer), 'consumer class must be subclass of ArkhamConsumer' has_kwargs = bool(inspect.getargspec(consumer.consume.im_func).keywords) if not has_kwargs: ArkhamWarning.warn('consume function should have **kwargs.') runner = ArkhamConsumerRunner( worker_cls, consumer, find_config(cmd_args.config_path, cmd_args.entry_point), cmd_args.consumer_name ) runner.start()
def rpc_entry(): cmd_args = parse_arguments() ArkhamService.init_config(find_config(cmd_args.config_path, cmd_args.entry_point)) server = load_entry_point(cmd_args.entry_point) assert isinstance(server, ArkhamRPCServer), 'consumer class must be subclass of ArkhamRPCServer' server.start(cmd_args.consumer_name)
def consumer_entry(): cmd_args = parse_arguments() consumer = load_entry_point(cmd_args.entry_point) assert inspect.isclass(consumer), "consumer must be a class" assert issubclass(consumer, ArkhamConsumer), "consumer class must be subclass of ArkhamConsumer" has_kwargs = bool(inspect.getargspec(consumer.consume.im_func).keywords) if not has_kwargs: ArkhamWarning.warn("consume function should have **kwargs.") runner = _ArkhamConsumerRunner( consumer, find_config(cmd_args.config_path, cmd_args.entry_point), cmd_args.consumer_name ) runner.start()