V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
scalaer
V2EX  ›  问与答

问个 akka stream 的问题

  •  
  •   scalaer · 2020-04-07 17:45:24 +08:00 · 598 次点击
    这是一个创建于 1981 天前的主题,其中的信息可能已经有所发展或是发生改变。

    打算从 issues 入手读 akka 源码, 给 stream operator 写写文档示例,

    lazy source 的描述:

    
      /**
       * Defers invoking the `create` function to create a future source until there is downstream demand.
       *
       * The returned source will emit downstream and behave just like it was the outer source. Downstream completes
       * when the created source completes and fails when the created source fails.
       *
       * Note that asynchronous boundaries (and other operators) in the stream may do pre-fetching which counter acts
       * the laziness and will trigger the factory immediately.
       *
       * The materialized future value is completed with the materialized value of the created source when
       * it has been materialized. If the function throws or the source materialization fails the future materialized value
       * is failed with the thrown exception.
       *
       * If downstream cancels or fails before the function is invoked the materialized value
       * is failed with a [[akka.stream.NeverMaterializedException]]
       */
      def lazySource[T, M](create: () => Source[T, M]): Source[T, Future[M]] =
    
    

    请教下 v 友什么场景会使用到lazy source啊, 实在想不到

    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5014 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:41 · PVG 13:41 · LAX 22:41 · JFK 01:41
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.