Registering frameworks
In this recipe, we will learn how frameworks register in Mesos to receive offers and state updates.
How to do it...
We will create the scheduler.go
file and implement our framework inside of it.
Before we start, we need to define some globals and imports that we will need later:
import ( "bufio" "bytes" "log" "net/http" "os" "strconv" "strings" "github.com/golang/protobuf/jsonpb" ) // Url to Mesos master scheduler API const schedulerApiUrl = "http://10.10.10.10:5050/api/v1/scheduler" // Current framework configuration var frameworkInfo FrameworkInfo // Marshaler to serialize Protobuf Message to JSON var marshaller = jsonpb.Marshaler{ EnumsAsInts: false, Indent: " ", OrigName: true, }
jsonpb.Marshaler
is a part of the Golang Protobuf binding. It's responsible for converting structs into JSON. We will use it to serialize the messages we send to Mesos. It's important to use a proper Marshaler...