Skip to content

Instantly share code, notes, and snippets.

View dasch's full-sized avatar
💭
LOOKING INTENTLY INTO THE VOID

Daniel Schierbeck dasch

💭
LOOKING INTENTLY INTO THE VOID
View GitHub Profile
# app/consumers/hello_consumer.rb
class HelloConsumer < Racecar::Consumer
subscribes_to "some-topic"
def process(message)
puts "Received message: #{message.value}"
end
end
class Consumer
class Fetcher
def initialize(input, output)
@input, @output = input, output
@running = true
end
def run
while @running
class IoFuture
def initialize(io, &block)
@io, @block = io, block
end
def to_io
@io
end
def value
module SearchQueryIndexer exposing (main)
import Stream exposing (Stream, Pipeline)
main : Pipeline
main =
Stream.readFrom "searches"
|> Stream.filter (\search -> search.resultCount > 0)
module Kafka.Consumer where
import Kafka
type alias Config =
{ groupId : String
, checkpointInterval : Maybe Int
, checkpointThreshold : Maybe Int
, heartbeatInterval : Int
}
module Aggregate exposing (..)
type alias Aggregate cmd error event state =
{ init : state
, apply : event -> state -> state
, handle : cmd -> state -> Result error event
}
type alias Coder cmd event =
{ decodeEvent : String -> Result String event
impressions : Stream (ImpressionId, Impression)
clicks : Stream (ImpressionId, Click)
-- One element per key with lists of input elements.
matches : Stream (ImpressionId, (List Impression, List Click))
matches =
Stream.join impressions clicks
-- One element per input-pair match.
matches : Stream (ImpressionId, (Impression, Click))
module Foosball.Game exposing (..)
type Team = BlueTeam | RedTeam
type alias Player = String
type alias Score = Int
type Event
= PlayerAdded { team : Team, player : Player }
| PlayerRemoved { player : Player }
| ScoreAdded { team : Team, score : Score }
@dasch
dasch / Kafka.elm
Last active August 7, 2021 06:09
Mock stream processing API in Elm
module Kafka exposing (..)
type alias KafkaRecord =
{ topic : String
, partition : Int
, offset : Int
, key : Maybe String
, value : Maybe String
}
@dasch
dasch / Kafka.elm
Last active January 29, 2017 03:30
module Kafka exposing (..)
import Stream exposing (Source, Sink)
source : String -> Source String String
sink : String -> Sink String String