GopherCon 2014

MongoDB y Go, la mejor combinación para almacenar información

Gustavo Niemeyer, Steve Francia  · 

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

so I'd like to invite Steve Frances to join me on stage Steve works at MongoDB how does that look and my mic yep yes all right so wow this is a great crowd look at this crowd yeah you know what before we start I just want to say this is an amazing community

and it's great to see all these faces and thank you all for coming and I hope you find what we're about to present valuable so we're going to talk about MongoDB go and mango and before we start into that I just want to talk a little bit my role

at MongoDB is I'm it's a pretty unique role I'm responsible for integrations with all the programming languages we support internally over a dozen and it's given me a really unique vantage point of how to work all the different languages work

and the interactions how the different communities work and one thing it's really taught me is given me a profound and deep appreciation of go and this community that we have here one thing that's common through all these languages is there's a

need to persist structured data and not only to persist it but to be able to take the structured data and retrieve it back into that same take the persistent data and retrieve it back into the same structure that we had originally and so I want to talk about

one solution to do that which is called be song so be saan is inspired by Jason but it's a binary format it has rich support for types and unlike Jason it's optimized for scanning so you can have deeply nested structures and it will optimize for finding

only that the values nested without having to traverse the entire tree and so I want to do a little demo with serialization within B song so we have a regular go struct here a person you'll notice we have a birthday with an actual date type which is something

that doesn't work well in a lot of other serialization formats like like Jason and so we're going to marshal it this is struct into byte slice and then we're going to take the byte slice and unmarshal it into a new into a new struct and we'll

run the code and you can see that the transformation is a 1 it works both ways so I'm going to talk now about MongoDB so a lot of people heard of MongoDB maybe some of you used it we know it's a one thing we commonly hear is a document database but

MongoDB is actually a document database for Beast on documents and beasts on documents in our world is really equivalent to a go struct so when you think about it MongoDB is actually a database for go structs right you can actually disable a lot of people

think about mobile DB as a JavaScript database because when you log into the shell the first thing you get is a JavaScript environment but it's you know it's really not it's a it's implemented in C++ and you can even disable JavaScript entirely

private and so so for us the way we interact with with MongoDB from go is through the mango driver which which gustavo is the primary author of so the story behind mango was in around i started writing and go more seriously around mid 2010 and around that

time I started wondering where do I put my data right there were not a lot of options by then the language was released by in the end of 2009 so it were just a few months in the wild and the first thing I did was you know as as we do is to try to implement

my own thing I started to create a small memory map database but so economical I work it on the on I created the the or am later that is used both by launchpad and by lens by landscape and by Ubuntu one as well I created that layer that communicates with Postgres

and it can also make it with my sickle and sickle light and so on and although I like it it was an extra layer and I really did not want to do that I wanted to have a you know first class object so instead of my one Abby database was was going to be something

that could store those those those values directly into the database and although that that was was doable and it still is I mean there's a lot of nice people working on that as we have seen yesterday in the talks I you know white and database with a complete

feature set takes a lot of time right and I really wanted I didn't want to want to spend my time just doing that I wanted just to unlock all their applications that I wanted to invest in so that's that's the background of red came from and by now

I appreciate what would it be by the end of 2011 nobody being started to sponsor the project as well so I I appreciate it and most of it was written that the the bulk of the project is written over a week in in Christmas of 2010 and then you know started to

be used at canonical eventually and by people in the wild so I wanted to spend some time then just showing you guys a a lot of people you know like the interface so it's going to be a lightweight talk just want to show you guys how to basic start working

on it so that you know you can then it makes sense as well because this is the first go conference so I wanted to start from the basic from the bare-bones so when it connects with with with mango you you dial which is a usual name for for connecting method

and go and you you use that same interface which is which is very straightforward as it should be right whether you're connected to a single server whether you're connecting to the replica set or if you're connecting to a charter deployment with

several machines and this is the exact same thing the driver behind the scenes will be trying to figure out what's the actual servers that are part of that deployment and you know if there's a failover it's going to do the failover it will error

out to let you know that it your your your actual statement has failed but it will retry again block until you can do so all of those things are abstracted behind it's simple interface when you dial to get back a session which is basically a handle to

[ ... ]

Nota: se han omitido las otras 2.944 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.