Single Badger store to serve bite, transcription and any others.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Daniel Lim 9824c6a945 Input validation 2 years ago
backend-protobuf@a36ddf9a81 Added backend-protobuf as submodule 2 years ago
.env Forgot to update .env and README for env 2 years ago
.gitignore Initial commit 2 years ago
.gitmodules Added backend-protobuf as submodule 2 years ago
Dockerfile Copy backend-protobuf/go in Dockerfile 2 years ago
README.md Forgot to update .env and README for env 2 years ago
go.mod Store rework. Direct query for retrieval now. Fixes #2 2 years ago
go.sum Store rework. Direct query for retrieval now. Fixes #2 2 years ago
key.go Initial commit 2 years ago
main.go Input validation 2 years ago

README.md

backend-store

Single Badger store to serve bite, transcription and any others. Is kinda bite-centric, so required values revolve around a Bite. Receives stores through NATS while data is retrieved via a http api. Checks backend-permissions for permissions to access the store.

Relies on being behind a traefik instance forwarding auth to backend-auth for authentication

Environment Variables

Supply environment variables by either exporting them or editing .env.

ENV Description Default
DBPATH Path to store badger files in. Please make sure it exists. /tmp/badger
NATS Host and port of nats nats://localhost:4222
LISTEN Host and port to listen on :80
PERMISSIONS_HOST URL of backend-permissions http://permissions

Key format

Takes in three variables: type, key and start. Type is the type of data to be inserted, e.g. bite or transcription. Key is the id of the conversation the bite was said in. Start is the Epoch timestamp of the start of the Bite.

NATS

Refer to protobuf definitions in backend-protobuf.

Name What you do Accepted Protobuf
store Publish to Store

store

Succeeds or fails quietly, just logging errors.

API

Contents
Scan Store
Get Store

Scan Store

GET /:type/:key/scan

Get a list of start times that one can use to query individual bites.

Params

Name Type Description
type String Type of store to query. I.e. transcription or bite.
key String Conversation ID of bite to query.

Querystring

Name Type Description
from Epoch timestamp Time to start scanning from.
to Epoch timestamp Time to stop scanning at.

Success (200 OK)

All numbers are Unix epoch timestamps. starts goes on for as long as it needs to.

{
  "previous": 0,
  "starts: [0, 0, 0],
  "next": 0
}

Errors

Code Description
400 From/to are not unix epoch/Error marshalling key from params.
401 permissions denied permission for user to access this store.
500 Error scanning badger store.

Get Store

GET /:type/:key/start/:start

Get the bite at a specific timestamp.

Params

Name Type Description
type String Type of store to query. I.e. transcription or bite.
key String Conversation ID of bite to query.
start Epoch timestamp Timestamp of the bite.

Success (200 OK)

Raw data of the bite.

Errors

Code Description
400 Error marshalling key from params/start was not a valid Epoch timestamp.
401 permissions denied permission for user to access this store.
500 Error retrieving bite from store.