https://github.com/sofyan48/wahoo
Data stream library with kinesis
https://github.com/sofyan48/wahoo
aws data data-stream event kinesis stream
Last synced: 2 months ago
JSON representation
Data stream library with kinesis
- Host: GitHub
- URL: https://github.com/sofyan48/wahoo
- Owner: sofyan48
- Created: 2019-12-31T22:18:55.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-01T19:56:59.000Z (about 6 years ago)
- Last Synced: 2025-04-11T19:09:59.063Z (9 months ago)
- Topics: aws, data, data-stream, event, kinesis, stream
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WAHOO
Data Streamer with AWS Kinesis
## Getting Started
### Install
```bash
go get github.com/sofyan48/wahoo
```
### Producer
```golang
package main
import (
"fmt"
"os"
"github.com/joho/godotenv"
"github.com/sofyan48/wahoo/api"
"github.com/sofyan48/wahoo/config"
)
func main() {
godotenv.Load()
cfg := config.Configure()
cfg.AwsAccessKeyID = os.Getenv("ACCESS_KEY")
cfg.AwsSecretAccessKey = os.Getenv("SECRET_KEY")
cfg.APArea = os.Getenv("REGION")
cfg.StreamName = os.Getenv("STREAM_NAME")
cfg.ShardID = os.Getenv("SHARD_ID")
client := config.NewConfig().Credential(cfg).New()
shardID, err := config.NewConfig().GetShardID(client, "TRIM_HORIZON")
if err != nil {
fmt.Println("Error :", err)
os.Exit(0)
}
producer := api.NewProducer(client, shardID)
data := []byte("{\"data\": {\"CompanyCode\": \"12345\",\"CustomerNumber\": \"ABC0012300DEF\",\"RequestID\": \"201507131507262221400000001975\",\"ChannelType\": \"6014\",\"CustomerName\": \"Customer BCA Virtual Account\",\"CurrencyCode\": \"IDR\",\"PaidAmount\": \"150000.00\",\"TotalAmount\": \"150000.00\",\"SubCompany\": \"00000\",\"TransactionDate\": \"15/03/2014 22:07:40\",\"Reference\": \"1234567890\",\"DetailBills\": [],\"FlagAdvide\": \"N\",\"Additionaldata\": \"\"}\n}")
response, err := producer.Publish(data, "keys")
if err != nil {
fmt.Println("Error :", err)
os.Exit(0)
}
fmt.Println(response.ShardId)
}
```
### Consumer
```golang
package main
import (
"fmt"
"os"
"github.com/joho/godotenv"
"github.com/sofyan48/wahoo/api"
"github.com/sofyan48/wahoo/config"
)
func main() {
godotenv.Load()
cfg := config.Configure()
cfg.AwsAccessKeyID = os.Getenv("ACCESS_KEY")
cfg.AwsSecretAccessKey = os.Getenv("SECRET_KEY")
cfg.APArea = os.Getenv("REGION")
cfg.StreamName = os.Getenv("STREAM_NAME")
cfg.ShardID = os.Getenv("SHARD_ID")
client := config.NewConfig().Credential(cfg).New()
shardIter, err := config.NewConfig().GetShardIterator(client, "TRIM_HORIZON")
if err != nil {
fmt.Println("Error :", err)
os.Exit(0)
}
consumer := api.NewConsumer(client, shardIter)
data, err := consumer.GetRecord()
if err != nil {
fmt.Println("Error :", err)
os.Exit(0)
}
for _, i := range data.Records {
fmt.Println(string(i.Data))
}
}
```
### Describe Data
```golang
package main
import (
"fmt"
"os"
"github.com/joho/godotenv"
"github.com/sofyan48/wahoo/api"
"github.com/sofyan48/wahoo/config"
)
func main() {
godotenv.Load()
cfg := config.Configure()
cfg.AwsAccessKeyID = os.Getenv("ACCESS_KEY")
cfg.AwsSecretAccessKey = os.Getenv("SECRET_KEY")
cfg.APArea = os.Getenv("REGION")
cfg.StreamName = os.Getenv("STREAM_NAME")
cfg.ShardID = os.Getenv("SHARD_ID")
client := config.NewConfig().Credential(cfg).New()
shardIter, err := config.NewConfig().GetShardIterator(client, "TRIM_HORIZON")
if err != nil {
fmt.Println("Error :", err)
os.Exit(0)
}
describe := api.NewDescribe(client, shardIter)
describe.Describe()
}
```