Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mchmarny/kcm
Knative Event Sentiment Service
https://github.com/mchmarny/kcm
Last synced: 5 days ago
JSON representation
Knative Event Sentiment Service
- Host: GitHub
- URL: https://github.com/mchmarny/kcm
- Owner: mchmarny
- License: apache-2.0
- Created: 2019-04-23T17:42:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-02-14T20:58:17.000Z (over 1 year ago)
- Last Synced: 2024-06-21T04:52:29.031Z (5 months ago)
- Language: Go
- Homepage:
- Size: 4.35 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kcm
Simple Knative service that scores the sentiment of Cloud Events content. The posted event has to have either `text/plain` or `application/json` content type.
## Prerequisites
* [Knative](https://github.com/knative/docs/blob/master/install) installed
* Configured [outbound network access (https://github.com/knative/docs/blob/master/serving/outbound-network-access.md)
* Installed [Knative Eventing](https://github.com/knative/docs/tree/master/eventing) using the `release.yaml` file## Deployment
If the posted event is a `JSON` structure, you must provide `TEXT_PATH` env var holding the full x-path of the text that will be scored. To score the content of Tweet for example you would pass `text`. You can edit it in the `service.yaml` file.
To deploy this service, simply apply it using `kubectl`
```shell
kubectl apply -f service.yaml -n demo
```The response should be
```shell
service.serving.knative.dev "kcm" configured
```To check if the service was deployed successfully you can check the status using `kubectl get pods -n demo` command. The response should look something like this (e.g. Ready `3/3` and Status `Running`).
```shell
NAME READY STATUS RESTARTS AGE
kcm-0000n-deployment-5645f48b4d-mb24j 3/3 Running 0 10s
```## Response
The service creates a response event based on the posted event. That allows it to be used as a opaque step in eventing pipeline. For example if the posted event was a tweet
```shell
Context Attributes,
specversion: 0.2
type: com.twitter
source: https://twitter.com/api/1
id: 1111-2222-3333-4444-5555-6666
time: 2018-04-05T03:56:24Z
contenttype: application/json
Data,
{
"text": "In preparation for NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team",
...
}
```The response event would be of `type: com.twitter.scored` (appending `.scored` to whatever was the original event type and injecting event `sentiment` sentiment (type `map[magnitude:0.2 score:0.2]`) which will carey the sentiment score to allow the subsequent steps in the event pipeline to implement logic over them.
```shell
Context Attributes,
specversion: 0.2
type: com.twitter.scored
source: https://twitter.com/api/1
id: 1111-2222-3333-4444-5555-6666
time: 2018-04-05T03:56:24Z
contenttype: application/json
Extensions,
sentiment: map[magnitude:0.2 score:0.2]
Data,
{
"text": "In preparation for NFL lockout, I will be spending twice as much time analyzing my fantasy baseball team",
...
}
```## 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.