Skip to content

Instantly share code, notes, and snippets.

View tardieu's full-sized avatar

Olivier Tardieu tardieu

View GitHub Profile
@tardieu
tardieu / client.go
Last active November 8, 2022 02:31
Knative sticky revisions: example golang client
package main
import (
"fmt"
"net/http"
"os"
)
const header = "Knative-Serving-Tag"
@tardieu
tardieu / server.go
Last active November 8, 2022 01:59
Knative sticky revisions: example golang server
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
// http request handler
@tardieu
tardieu / aapl.py
Created June 21, 2021 13:21
aapl.py - pipeline
source.send_to(lambda event: sink.append(event))
@tardieu
tardieu / aapl.py
Last active June 21, 2021 13:25
aapl.py - sink
sink_config = dict(kind='slack-sink',
channel=slack_channel,
webhookUrl=slack_webhook)
sink = rayvens.Stream('slack', sink_config=sink_config)
@tardieu
tardieu / aapl.py
Last active June 21, 2021 13:25
aapl.py - source
source_config = dict(
kind='http-source',
url='http://financialmodelingprep.com/api/v3/quote-short/AAPL?apikey=demo',
period=3000)
source = rayvens.Stream('http', source_config=source_config)
@tardieu
tardieu / aapl.py
Created June 21, 2021 13:19
aapl.py - initialization
import ray
import rayvens
ray.init()
rayvens.init()
@tardieu
tardieu / aapl.py
Last active June 21, 2021 13:32
aapl.py - actor
@ray.remote
class Comparator:
def __init__(self):
self.last_quote = None
def append(self, event):
payload = json.loads(event) # parse event payload to json
quote = payload[0]['price'] # extract AAPL quote
if self.last_quote:
if quote > self.last_quote:
@tardieu
tardieu / source.yaml
Created September 6, 2019 20:01
Knative Event Source YAML
apiVersion: ibmcloud.ibm.com/v1alpha1
kind: Composable
metadata:
name: source
spec:
template:
apiVersion: sources.eventing.knative.dev/v1alpha1
kind: KafkaSource
metadata:
name: source
@tardieu
tardieu / source.js
Created September 6, 2019 19:58
Knative Event Source
let { Bundle, EventStreams } = require('solsa')
let bundle = new Bundle()
bundle.kafka = new EventStreams({ name: 'kafka', plan: 'standard' })
bundle.topic = new bundle.kafka.Topic({ name: 'topic', topicName: 'MyTopic' })
bundle.source = new bundle.topic.Source({ name: 'source', sink: { name: 'test-sink' } })
module.exports = bundle
@tardieu
tardieu / topic.yaml
Last active September 6, 2019 19:40
Event Streams Topic YAML
apiVersion: ibmcloud.ibm.com/v1alpha1
kind: Topic
metadata:
name: topic
spec:
bindingFrom:
name: kafka
topicName: MyTopic