text stringlengths 0 1.82k |
|---|
[166.24 --> 169.22] but nothing that we felt would be enough for us. |
[169.22 --> 175.66] So we ended up creating a framework at the time that framework was in Ruby |
[175.66 --> 179.26] called Praxis that basically allowed you to write that design code. |
[179.38 --> 183.04] And then the framework would leverage a design at runtime. |
[184.78 --> 186.38] And fast-forwarding forward, |
[187.56 --> 190.06] RISCALE kind of shifted towards Go. |
[190.06 --> 194.68] And I thought it would be good to see if we could do something in Latin Go. |
[195.80 --> 198.80] And to be honest, I wasn't sure initially that would be possible. |
[200.52 --> 203.40] So I played around with a few things. |
[204.94 --> 206.90] And it took me about a year, really, |
[207.04 --> 210.86] to come up with something that started to look like it may work. |
[210.86 --> 219.66] And so there were two big aha moments in that kind of research phase. |
[219.90 --> 224.86] One was the realization that code generation was the perfect approach |
[224.86 --> 228.72] for achieving the goal of keeping the design and implementation separate |
[228.72 --> 231.60] while making sure that the design is directly enforced. |
[232.22 --> 237.40] And the second realization was that the design should be written in a DSL |
[237.40 --> 241.46] so that the language used to describe the API used the right terms, right? |
[241.48 --> 245.14] You want to talk about resources, actions, responses, requests, |
[245.52 --> 249.58] and you don't want to have to deal with programming language artifacts. |
[250.94 --> 254.12] So that DSL would have to be a Go DSL, obviously, |
[254.30 --> 256.30] so that it could be understood right away |
[256.30 --> 261.08] and also so that it's still possible to use the Go language when it's needed. |
[262.36 --> 265.12] So fast-forward a year and a half, |
[265.12 --> 269.60] and I have to say that the result turned out a lot better than I thought it would be. |
[270.46 --> 272.64] And I think a lot of the credits goes to the Go language. |
[273.32 --> 276.24] The Go language provides very simple and powerful mechanism |
[276.24 --> 278.72] to create that DSL. |
[279.14 --> 283.60] It also has very good code analysis support, which is essential, |
[284.12 --> 286.90] and very good generation packages, code generation packages, |
[287.68 --> 289.26] the template package in particular. |
[289.86 --> 291.76] So all of that put together, |
[291.76 --> 294.56] I think we end up today with something that is actually very interesting, |
[295.06 --> 300.08] and we've started using Goa fairly extensively here at RightScale. |
[300.32 --> 301.50] So that's great. |
[301.86 --> 305.06] So just kind of like a high-level detail. |
[305.32 --> 309.98] So Goa is a framework for using kind of DSL |
[309.98 --> 314.44] that's written in Go to generate HTTP APIs. |
[314.44 --> 316.26] Yep, exactly. |
[317.12 --> 318.46] And it, you know, |
[318.60 --> 321.40] from that design, |
[321.56 --> 323.82] from that DSL, |
[324.14 --> 327.22] which is Go code with basically the DSL, |
[327.28 --> 331.78] you can think of it as a lot of package-level functions |
[331.78 --> 334.08] that you invoke and that are recursive. |
[334.08 --> 336.16] So you call a top-level function, |
[336.30 --> 336.68] let's say, |
[336.80 --> 337.38] called API, |
[338.04 --> 342.90] and you then embed other function cores in it |
[342.90 --> 345.68] where you define every single property of the API, |
[345.82 --> 346.36] like the title, |
[346.52 --> 346.92] the description, |
[347.08 --> 347.34] et cetera. |
[347.86 --> 349.80] So when you look at it, |
[349.84 --> 351.18] it's actually not too ugly. |
[351.50 --> 353.40] You can actually understand it very well |
[353.40 --> 355.22] and follow what it's trying to do. |
[355.22 --> 357.32] And from that design, |
[357.58 --> 360.78] what happens is when you load the design, |
[360.88 --> 361.78] when you start the process |
[361.78 --> 363.60] that has that package linked in, |
[364.98 --> 367.78] because all of that design code |
[367.78 --> 370.16] lives in global viable, |
[370.80 --> 373.54] the Go runtime takes care of running all of that for you |
[373.54 --> 378.42] and you end up with a lot of in-memory data structures |
[378.42 --> 380.30] that describe your API. |
[381.58 --> 383.64] And those are simple, |
[383.64 --> 385.58] nothing special, |
[386.02 --> 386.82] Go data structures |
[386.82 --> 388.00] that you can look at, |
[388.16 --> 388.42] inspect, |
[388.68 --> 390.74] and use to generate pretty much anything. |
[391.32 --> 392.54] So it's quite nice |
[392.54 --> 394.24] because you start from a language |
[394.24 --> 395.18] that is easy to use |
[395.18 --> 397.18] from a human point of view |
[397.18 --> 399.70] and you end up with data structures |
[399.70 --> 401.00] that are very nice to handle |
[401.00 --> 402.62] from a programmatic point of view. |
[404.26 --> 406.78] And so Goa comes with a few built-in |
[406.78 --> 410.44] code generation outputs. |
[410.76 --> 412.08] One is the glue code |
[412.08 --> 413.98] that produces the load of an HTTP server |
[413.98 --> 415.96] with the user-provided handlers. |
[416.58 --> 418.52] And that code takes care of validating |
[418.52 --> 419.66] the incoming requests |
[419.66 --> 421.30] according to the validation rules |
[421.30 --> 422.18] described in language. |
[422.76 --> 425.38] It also builds convenient data structures |
[425.38 --> 427.52] for accessing the request state |
[427.52 --> 428.68] and writing the response. |
[428.68 --> 431.48] So you end up with code |
[431.48 --> 432.80] that you have to write as the user, |
[432.96 --> 434.46] which is fairly small, right? |
[434.48 --> 435.58] You don't have to do |
[435.58 --> 436.36] all the validation |
[436.36 --> 437.64] that you usually have to do |
[437.64 --> 439.60] and you don't have to bind |
[439.60 --> 440.32] the request body |
[440.32 --> 441.14] to some data structure. |
[441.30 --> 442.88] All of that is done already. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.