Skip to content

mchmarny/twitter-search-dapr-component-example

Repository files navigation

twitter-search-dapr-component-example

Example of how to use Twitter search input component in godapr.

Prerequisites

dapr

To run this demo locally, you will have to have install dapr. The instructions for how to do that can be found here.

Twitter

To configure the dapr input component to query Twitter API you will also need the consumer key and secret. You can get these by registering a Twitter application here.

Setup

Assuming you have all the prerequisites mentioned above you can demo this dapr pipeline in following steps. First, start by cloning this repo:

git clone https://github.com/mchmarny/twitter-search-dapr-component-example.git

and then navigate into the twitter-search-dapr-component-example directory:

cd twitter-search-dapr-component-example

Component

Insert your Twitter API secrets into the components/twitter.yaml file.

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: tweets
spec:
  type: bindings.twitter
  metadata:
  - name: consumerKey
    value: ""
  - name: consumerSecret
    value: ""
  - name: accessToken
    value: ""
  - name: accessSecret
    value: ""
  - name: query
    value: "serverless"

The query is the twitter search query for which you want to receive tweets.

Run

Once the Twitter API consumer and access details are set, you are ready to run:

dapr run go run handler.go main.go \
         --app-id "consumer" \
         --app-port 8081 \
         --protocol http \
         --port 3500

Assuming everything went OK, you should see something like this:

ℹ️  Updating metadata for app command: handler.go main.go
✅  You're up and running! Both Dapr and your app logs will appear here.

Hope you found this demo helpful.

Disclaimer

This is my personal project and it does not represent my employer. I take no responsibility for issues caused by this code. I do my best to ensure that everything works, but if something goes wrong, my apologies is all you will get.

License

This software is released under the Apache v2 License

About

Twitter search dapr input component example

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published