浮士德库怎么在python中使用

  介绍

今天就跟大家聊聊有关浮士德库怎么在python中使用,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

python的优点有哪些

1,简单易用,与C/c++、Java、c#等传统语言相比,python对代码格式的要求没有那么严格;2,python属于开源的,所有人都可以看到源代码,并且可以被移植在许多平台上使用;3,python面向对象,能够支持面向过程编程,也支持面向对象编程;4,python是一种解释性语言,python写的程序不需要编译成二进制代码,可以直接从源代码运行程序;5,python功能强大,拥有的模块众多,基本能够实现所有的常见功能。

<强> 1,实时读取和处理卡夫卡中的数据。

利用faust.App创建浮士德应用程序,并配置应用程序名称,Kafkabroker和序列模式。

接着,我们创建了一个主题,它与卡夫卡中的主题相对应。

《浮士德》使用Python3.6 +异步语法异步,定义异步函数打招呼,并将其注册为浮士德应用程序的代理。该函数接收实时数据集问候,并异步输出每个数据。

 import 《浮士德》
  ,
  时间=app  faust.App (
  ,,,& # 39;hello-world& # 39;
  ,,,代理=& # 39;卡夫卡://localhost: 9092 & # 39;
  ,,,value_serializer=& # 39;生# 39;
  )
  ,
  时间=greetings_topic  app.topic(& # 39;问候# 39;)
  ,
  @app.agent (greetings_topic)
  async  def 问候(问候):
  ,,,async  for  greeting 拷贝的问候:
  ,,,,,,,印刷(问候)
<>之前,美元faust  -A  hello_world  worker  -l 信息

<强> 2,充分利用Python的类型提示,可以轻松定义数据模型。

 import 《浮士德》
  ,
  class 问候(faust.Record):
  ,,,from_name: str
  ,,,to_name: str
  ,
  时间=app  faust.App (& # 39; hello-app& # 39;,,代理=& # 39;卡夫卡://localhost # 39;)
  时间=topic  app.topic (& # 39; hello-topic& # 39;,, value_type=问候)
  ,
  @app.agent(主题)
  async  def 你好(问候):
  ,,,async  for  greeting 拷贝的问候:
  ,,,,,,,印刷(f # 39; Hello 得到{greeting.from_name},用{greeting.to_name} & # 39;)
  ,
  @app.timer(间隔=1.0)
  async  def  example_sender(应用):
  ,,,await  hello.send (
  ,,,,,,,value=https://www.yisu.com/zixun/Greeting (from_name=案∈康隆?to_name=澳恪?,
  )
  
  if __name__==癬_main__”:
  app.main () 

看完上述内容,你们对浮士德库怎么在python中使用有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。

浮士德库怎么在python中使用