gouda : go unified data accessors
Post on 13-Jul-2015
435 Views
Preview:
TRANSCRIPT
Go Language
Go for Google
Public release : November 2009
A new release every two weeks
Vibrant mailing list
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
Example
2 entity classes : Person & Car
A Person has many Carsid Name Age
1 Bob 12
2 Alice 23
3 Marc 18
id Owner_id Plate Model
1 2 AAA78 Scenic
2 3 BBB92 308
3 2 CCC99 Traban
Looking for :
Person with age = 18 or age >= 20 ordered by id desc
Their cars
1st method : Direct access
Direct file or structure access (i.e. no queries)
Files, CSV, XML perusing…
Hey, let’s hunt for our data !
Nota : Ruby is quite expressive !
Packages available in Go Standard Library
2nd method : Use bindings
Call a subsystem through a library
Use SQL (or a derivative)
Developers are in charge
Well, let’s ask our database…
Go bindings available for MySQL, PostgreSQL, MongoDB…
3rd method : Use an ORM
Developers ask for objects not data
Generally database agnostic
Still no compiler verification
I don’t even want to know where you got it !
Some research studies on improving ORMs
Until GoUDA none available in Go…
4th method : Native query language
Calling object stores right from the code
Need aware compilers
It’s a kind of magic !
Only found in LINQ
Results of research project Cω
Papers are hard to find…
Objectives
Meant for developers
Should be
Easy to use
Easy to read
Expressive
Self documenting
Backend agnostic
Behind the scene
Persons
A call to Or creates another Condition referencing the objects
Condition 0Age == 18
Condition 1Age >= 20
Condition 2Or
Behind the scene
Persons
A call to Where on the Model returns a ModelRelation instance
Condition 0Age == 18
Condition 1Age >= 20
Condition 2Or
ModelRelationCondition : cond 2
Behind the scene
Persons
All successive calls fill the object and then return a reference to it
Condition 0Age == 18
Condition 1Age >= 20
Condition 2Or
ModelRelationCondition : cond 2
Order : id DESC
Behind the scene
The last call to All uses the Model to fetch the requested objectsand returns an array
Condition 0Age == 18
Condition 1Age >= 20
Condition 2Or
ModelRelationCondition : cond 2
Order : id DESCPersons
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
Conclusion
A nice and challenging project
Go really is a fun language to use
Might need more work before production
Go is also experimental !
Go For It ! github.com/zetaben/gouda
top related