Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building an IoT platform with Go and Python

David Majda
September 13, 2018

Building an IoT platform with Go and Python

Go and Python are very different languages, but do they complement each other? At Energomonitor, we think so, and we used both to build an IoT platform that processes and analyzes data from our devices in real-time. Where did we use Go? Where did we use Python? Why? What are the strong points of each language? And what are the weak ones? How do the ecosystems compare? And what about the daily operational experience? Finally, what would we do differently knowing what we know today? These are all questions I will attempt to answer, based on our multi-year experience.

Presented at Golang Prague #3.

Details: https://www.meetup.com/Prague-Golang-Meetup/events/251802529/

David Majda

September 13, 2018
Tweet

More Decks by David Majda

Other Decks in Programming

Transcript

  1. Building an IoT platform with Go and Python David Majda

    @dmajda Golang Prague #3 · Prague · 13 September, 2018
  2. Simple Easy to learn Fast development Reliable No complaints Simple

    Easy to learn Fast development Reliable Tons of complaints
  3. type Device struct { Type string `json:"type"` SN *string `json:"sn,omitempty"`

    // pointer! GatewaySN *string `json:"gateway_sn,omitempty"` // pointer! Channel *uint `json:"channel,omitempty"` // pointer! } input := `{"type": "Gateway", "sn": "3FCF54AADCB6E7DC"}` device := Device{} json.Unmarshal([]byte(input), &device) fmt.Println(device) // {Gateway 0x1050c160 <nil> <nil>} output, _ := json.Marshal(device) fmt.Printf("%s\n", output) // {"type":"Gateway","sn":"3FCF54AADCB6E7DC"}
  4. @JsonTypeInfo( use = JsonTypeInfo.Id.NAME, include = As.PROPERTY, property = "type"

    ) @JsonSubTypes({ @JsonSubTypes.Type(value = Gateway.class, name = "gateway"), @JsonSubTypes.Type(value = Sensor.class, name = "sensor") }) public class Device { } @JsonTypeName("gateway") public class Gateway extends Device { public String sn; } @JsonTypeName("sensor") public class Sensor extends Device { public String gatewaySN; public int channel; }
  5. { "type": "gateway", "gateway": { "sn": "3FCF54AADCB6E7DC" } } {

    "type": "sensor", "sensor": { "gateway_sn": "3FCF54AADCB6E7DC", "channel": 5 } }
  6. Threads 90’s technology asyncio Parallel world Poor usability Bad libraries

    Goroutines & channels Model the real world really nicely