GoUDA : Go Unified Data Accessors

597 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
597
On SlideShare
0
From Embeds
0
Number of Embeds
12
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

GoUDA : Go Unified Data Accessors

  1. 1. GoUDA : Go Unified Data Accessors Accessing Data in Go Benoît Larroque ECP SIO 04/12/2010
  2. 2. Contents  The Go language  Programming using Data  GoUDA
  3. 3. The Go Language Accessing Data in Go
  4. 4. Go Language  Go for Google  Public release : November 2009  A new release every two weeks  Vibrant mailing list
  5. 5. From its authors, Go is…  Simple : easy to code  Safe : no pointer arithmetic, garbage collected  Concurrent : built in concurrency  Fun : feels dynamic  Open source : permissive licence
  6. 6. Looks kind of like C From sum.go
  7. 7. Programming using Data Accessing Data in Go
  8. 8. Example  2 entity classes : Person & Car  A Person has many Cars id Name Age id Owner_id Plate Model 1 Bob 12 1 2 AAA78 Scenic 2 Alice 23 2 3 BBB92 308 3 Marc 18 3 2 CCC99 Traban  Looking for :  Person with age = 18 or age >= 20 ordered by id desc  Their cars
  9. 9. 1st method : Direct access Hey, let’s hunt for our data !  Direct file or structure access (i.e. no queries)  Files, CSV, XML perusing… Nota : Ruby is quite expressive !  Packages available in Go Standard Library
  10. 10. 2nd method : Use bindings Well, let’s ask our database…  Call a subsystem through a library  Use SQL (or a derivative)  Developers are in charge  Go bindings available for MySQL, PostgreSQL, MongoDB…
  11. 11. 3rd method : Use an ORM I don’t even want to know where you got it !  Developers ask for objects not data  Generally database agnostic  Still no compiler verification  Some research studies on improving ORMs  Until GoUDA none available in Go…
  12. 12. 4th method : Native query language It’s a kind of magic !  Calling object stores right from the code  Need aware compilers  Only found in LINQ  Results of research project Cω  Papers are hard to find…
  13. 13. Introducing GoUDA Accessing Data in Go
  14. 14. Objectives  Meant for developers  Should be  Easy to use  Easy to read  Expressive  Self documenting  Backend agnostic
  15. 15. Architecture  Layered architecture User Space Models Backend Adaptors
  16. 16. Ideal Query
  17. 17. Ideal Query
  18. 18. Actual Query
  19. 19. Actual Query : why ? There are no class in Go Types are final Can’t inject methods at runtime
  20. 20. Behind the scene Persons Persons is an instance of Model object
  21. 21. Behind the scene Persons Condition 0 Age A call to gouda.F initializes a Condition
  22. 22. Behind the scene Persons Condition 0 Age == 18 A call to Eq sets the type and value of the Condition
  23. 23. Behind the scene Persons Condition 0 Condition 1 Age == 18 Age >= 20 Same with the second Condition
  24. 24. Behind the scene Condition 2 Persons Or Condition 0 Condition 1 Age == 18 Age >= 20 A call to Or creates another Condition referencing the objects
  25. 25. Behind the scene ModelRelation Condition 2 Persons Condition : cond 2 Or Condition 0 Condition 1 Age == 18 Age >= 20 A call to Where on the Model returns a ModelRelation instance
  26. 26. Behind the scene ModelRelation Condition 2 Persons Condition : cond 2 Or Order : id DESC Condition 0 Condition 1 Age == 18 Age >= 20 All successive calls fill the object and then return a reference to it
  27. 27. Behind the scene ModelRelation Condition 2 Persons Condition : cond 2 Or Order : id DESC Condition 0 Condition 1 Age == 18 Age >= 20 The last call to All uses the Model to fetch the requested objects and returns an array
  28. 28. Wrapping up  More than 2000 lines written  GoUDA can now “connects” to  MySQL : use a Go native binding  XML : self-contained in XMLAdaptor  Tested code (using gotest)  Has some support for associations  Open Source : MIT License
  29. 29. Conclusion  A nice and challenging project  Go really is a fun language to use  Might need more work before production  Go is also experimental !
  30. 30. Go For It ! github.com/zetaben/gouda

×