Developing lightweight computation at the DSG edge

Commit bec1ef82 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[apidote] De-hardcode API host and port from code


Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent 5b6c0979
...@@ -10,9 +10,12 @@ import ( ...@@ -10,9 +10,12 @@ import (
"uc-monitor-go-test/cnml" "uc-monitor-go-test/cnml"
) )
// Default settings
var api_host_port = "localhost:3000"
// AntidoteAddItemToSetInBucket save an item to a set in a bucket // AntidoteAddItemToSetInBucket save an item to a set in a bucket
func AntidoteAddItemToSetInBucket(bucket string, set string, item string) bool { func AntidoteAddItemToSetInBucket(bucket string, set string, item string) bool {
request := fmt.Sprintf("http://localhost:3000/set/add/%s/%s/%s", bucket, set, item) request := fmt.Sprintf("http://%s/set/add/%s/%s/%s", api_host_port, bucket, set, item)
response, err := http.Get(request) response, err := http.Get(request)
errCheck(err) errCheck(err)
...@@ -33,7 +36,7 @@ func AntidoteAddItemToSetInBucket(bucket string, set string, item string) bool { ...@@ -33,7 +36,7 @@ func AntidoteAddItemToSetInBucket(bucket string, set string, item string) bool {
// AntidoteReadRegisterInBucket read a LWWW register in a bucket // AntidoteReadRegisterInBucket read a LWWW register in a bucket
func AntidoteReadRegisterInBucket(bucket string, register string) string { func AntidoteReadRegisterInBucket(bucket string, register string) string {
request := fmt.Sprintf("http://localhost:3000/register/read/%s/%s", bucket, register) request := fmt.Sprintf("http://%s/register/read/%s/%s", api_host_port, bucket, register)
response, err := http.Get(request) response, err := http.Get(request)
errCheck(err) errCheck(err)
...@@ -54,7 +57,7 @@ func AntidoteReadRegisterInBucket(bucket string, register string) string { ...@@ -54,7 +57,7 @@ func AntidoteReadRegisterInBucket(bucket string, register string) string {
// AntidoteSetRegisterInBucket set a LWWW register in a bucket // AntidoteSetRegisterInBucket set a LWWW register in a bucket
func AntidoteSetRegisterInBucket(bucket string, register string, value string) bool { func AntidoteSetRegisterInBucket(bucket string, register string, value string) bool {
request := fmt.Sprintf("http://localhost:3000/register/set/%s/%s/%s", bucket, register, value) request := fmt.Sprintf("http://%s/register/set/%s/%s/%s", api_host_port, bucket, register, value)
response, err := http.Get(request) response, err := http.Get(request)
errCheck(err) errCheck(err)
...@@ -75,7 +78,7 @@ func AntidoteSetRegisterInBucket(bucket string, register string, value string) b ...@@ -75,7 +78,7 @@ func AntidoteSetRegisterInBucket(bucket string, register string, value string) b
// AntidoteRemoveRegisterInBucket remove (set null) a LWWW register in a bucket // AntidoteRemoveRegisterInBucket remove (set null) a LWWW register in a bucket
func AntidoteRemoveRegisterInBucket(bucket string, register string) bool { func AntidoteRemoveRegisterInBucket(bucket string, register string) bool {
request := fmt.Sprintf("http://localhost:3000/register/set/%s/%s/\\'\\'", bucket, register) request := fmt.Sprintf("http://%s/register/set/%s/%s/\\'\\'", api_host_port, bucket, register)
response, err := http.Get(request) response, err := http.Get(request)
errCheck(err) errCheck(err)
...@@ -96,7 +99,7 @@ func AntidoteRemoveRegisterInBucket(bucket string, register string) bool { ...@@ -96,7 +99,7 @@ func AntidoteRemoveRegisterInBucket(bucket string, register string) bool {
// AntidoteReadItemsFromSetInBucket read items from a set in a bucket // AntidoteReadItemsFromSetInBucket read items from a set in a bucket
func AntidoteReadItemsFromSetInBucket(bucket string, set string) []string { func AntidoteReadItemsFromSetInBucket(bucket string, set string) []string {
request := fmt.Sprintf("http://localhost:3000/set/read/%s/%s", bucket, set) request := fmt.Sprintf("http://%s/set/read/%s/%s", api_host_port, bucket, set)
response, err := http.Get(request) response, err := http.Get(request)
errCheck(err) errCheck(err)
...@@ -117,7 +120,7 @@ func AntidoteReadItemsFromSetInBucket(bucket string, set string) []string { ...@@ -117,7 +120,7 @@ func AntidoteReadItemsFromSetInBucket(bucket string, set string) []string {
// AntidoteRemoveItemFromSetInBucket removes an item from a set in a bucket // AntidoteRemoveItemFromSetInBucket removes an item from a set in a bucket
func AntidoteRemoveItemFromSetInBucket(bucket string, set string, item string) bool { func AntidoteRemoveItemFromSetInBucket(bucket string, set string, item string) bool {
request := fmt.Sprintf("http://localhost:3000/set/remove/%s/%s/%s", bucket, set, item) request := fmt.Sprintf("http://%s/set/remove/%s/%s/%s", api_host_port, bucket, set, item)
response, err := http.Get(request) response, err := http.Get(request)
errCheck(err) errCheck(err)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment