module Qian

Constants

VERSION

Attributes

disabled[RW]
kafka_config[RW]
logger_config[RW]
schema_path[RW]
schema_registry_url[RW]

Public Instance Methods

avro() click to toggle source

返回 Avro Instance

@return [Avro]

# File lib/qian.rb, line 85
def avro
  @avro
end
configure(&blk) click to toggle source

设置 Qian 配置

@return []

# File lib/qian.rb, line 37
def configure(&blk)
  blk.yield(Qian)

  #
  # Setting up
  #
  @kafka ||= Kafka.new(kafka_config[:connection])
  @avro ||= AvroTurf::Messaging.new(
    :registry_url => schema_registry_url, :schemas_path => schema_path)
end
disabled?() click to toggle source

是否禁用

@return [Boolean]

# File lib/qian.rb, line 54
def disabled?
  self.disabled
end
kafka_producer() click to toggle source

返回一个 Kafka Async Producer 实例

@return [Kafka::AsyncProducer]

# File lib/qian.rb, line 64
def kafka_producer
  return nil if disabled?
  @producer ||= @kafka.async_producer(kafka_config[:async_config])
end
logger() click to toggle source

返回 Qian::Logger

@return [Qian::Logger]

# File lib/qian.rb, line 75
def logger
  @logger || Qian::Logger.new(kafka_producer)
end
root() click to toggle source

当前 Qian lib 的路径

@return [Pathname]

# File lib/qian.rb, line 27
def root
  Pathname.new(File.expand_path(File.dirname(__FILE__)))
end
shutdown() click to toggle source

资源清理

@return [void]

# File lib/qian.rb, line 95
def shutdown
  # 关闭 Kafka Producer
  @producer.present? && @producer.shutdown
end