min_max_memory_usage_per_minute = Stream.interval(1000)
|> Stream.map fn(_) -> get_memory_usage end
|> Stream.chunk(60) # group every 60 seconds together
|> Stream.map &( {Enum.min(&1), Enum.max(&1)} )
|> Enum.each fn ({min, max) ->
send_to_graphite("min_memory_usage", min)
send_to_graphite("max_memory_usage", max)
end
Stream.interval(t) - produces a stream that emits value `:ok` every `t` milliseconds. Generally a building block for other functionality.
Stream.timer(t) - Produces a stream that emits one value `:ok` every `t` milliseconds. Shorthand for `Stream.interval(t) |> Stream.take(1)`. Very useful with Streamz.take_until/2, but I can't think of a whole lot of other uses off the top of my head. It is the compliment to interval and since it is trivial I think it should be included.
I'm a fan. I've used Rx.NET's Observables pretty extensively, and this is one of the first things I used in that API. So +1 from me.
I do think the value for interval should be able to be provided by the user. I like the idea of using a function to generate the value for each interval. :ok seems like a good default though.
Paul
--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.