V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
scalaer
V2EX  ›  问与答

问个 akka stream 的问题

  •  
  •   scalaer · Apr 7, 2020 · 780 views
    This topic created in 2213 days ago, the information mentioned may be changed or developed.

    打算从 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啊, 实在想不到

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1174 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:13 · PVG 02:13 · LAX 11:13 · JFK 14:13
    ♥ Do have faith in what you're doing.