Commit b6ea2c31 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Use kingpin

parent 75b4709a
......@@ -7,8 +7,10 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"github.com/streadway/amqp"
"gopkg.in/alecthomas/kingpin.v2"
)
type (
......@@ -47,6 +49,10 @@ type (
}
)
const (
version = "0.1.0"
)
// TODO put into config
var (
host = "hdf-portal.data.kit.edu"
......@@ -117,7 +123,6 @@ func handleInitialUpdates(initialUpdate deploymentUpdates) {
}
}
// fetch the services we are permitted to receive
func fetchConfiguredServices() []service {
req, err := http.NewRequest("GET", "https://"+host+"/backend/clientapi/config", nil)
failOnError(err, "fetching services")
......@@ -172,7 +177,7 @@ func pubSub(services []service) {
msgs, err := ch.Consume(
q.Name, // queue
"", // consumer
false, // auto-ack
false, // auto-ack
false, // exclusive
false, // no-local
false, // no-wait
......@@ -200,12 +205,26 @@ func pubSub(services []service) {
}
func main() {
services := fetchConfiguredServices()
app := kingpin.New("fumClient", "Client for the 'Federated user management in the Helmholtz Data Federation' project")
oneshot := app.Flag("oneshot", "Fetch deployments with HTTP. Do not use rabbitmq.").Short('1').Bool()
app.Author("Lukas Burgey")
app.Version(version)
// get input
kingpin.MustParse(app.Parse(os.Args[1:]))
// we first get the changes which happened while we were offline
initialUpdates := fetchInitialUpdates()
handleInitialUpdates(initialUpdates)
handleInitialUpdates(fetchInitialUpdates())
if !*oneshot {
// and the connect to the pub sub system for live updates
pubSub(services)
// fetch the services we are permitted to receive
services := fetchConfiguredServices()
// and then connect to rabbitmq for live updates for these services
pubSub(services)
}
}
Supports Markdown
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