ducky/devices

Paddy 2015-12-14 Parent:b6494e1a499e

15:c24a6c5fcd8c Go to Latest

ducky/devices/vendor/golang.org/x/net/PATENTS

Begin implementation on apiv1. Begin implementing the apiv1 package, which will define the first iteration of our API endpoints and logic. Each API package should be self-contained and able to run without depending on each other. Think of them as interfaces into manipulating the business logic defined in the devices package. The point is to have total control over backwards compatibility, as long as our business logic doesn't change. If that happens, we're in a bad place, but not as bad as it could be. This required us to pull in all our API tools; the api package, its dependencies, the scopeTypes package (so we can define scopes for our API), the trout router, etc. We also updated uuid to the latest, which now includes a license. Hooray? The new apiv1 package consists of a few things: * The devices.go file defines the types the API will use to communicate, along with some helpers to convert from API types to devices types. There's also a stub for validating the device creation requests, which I haven't implemented yet because I'm a pretty bad person. * endpoints.go just contains a helper function that builds our routes and assigns handlers to them, giving us an http.Handler in the returns that we can listen with. * handlers.go defines our HTTP handlers, which will read requests and write responses, after doing the appropriate validation and executing the appropriating business logic. Right now, we only have a handler for creating devices, and it doesn't actually do any validation. Also, we have some user-correctable errors being returned as 500s right now, which is Bad. Fortunately, they're all marked with BUG, so I can at least come back to them. * response.go defines the Response type that will be used for returning information after a request is executed. It may eventually get some helpers, but for now it's pretty basic. * scopes.go defines the Scopes that we're going to be using in the package to control access. It should probably (eventually) include a helper to register the Scopes, or we should have a collector service that pulls in all the packages, finds all their Scopes, and registers them. I haven't decided how I want to manage Scope registration just yet. We exported the getStorer function (now GetStorer) so other packages can use it. I'm not sure how I feel about this just yet. We also had to create a WithStorer helper method that embeds the Storer into a context.Context, so we can bootstrap in devicesd. We erroneously had Created in the DeviceChange struct, but there's no reason the Created property of a Device should ever change, so it was removed from the logic, from the struct, and from the tests. Our CreateMany helper was erroneously creating the un-modified Devices that were passed in, instead of the Devices that had sensible defaults filled. We created a _very minimal_ (e.g., needs some work before it's ready for production) devicesd package that will spin up a simple server, just so we could take a peek at our apiv1 endpoints as they'd actually be used. (It worked. Yay?) We should continue to expand on this with configuration, more information being logged, etc.

History
1 Additional IP Rights Grant (Patents)
3 "This implementation" means the copyrightable works distributed by
4 Google as part of the Go project.
6 Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 no-charge, royalty-free, irrevocable (except as stated in this section)
8 patent license to make, have made, use, offer to sell, sell, import,
9 transfer and otherwise run, modify and propagate the contents of this
10 implementation of Go, where such license applies only to those patent
11 claims, both currently owned or controlled by Google and acquired in
12 the future, licensable by Google that are necessarily infringed by this
13 implementation of Go. This grant does not include claims that would be
14 infringed only as a consequence of further modification of this
15 implementation. If you or your agent or exclusive licensee institute or
16 order or agree to the institution of patent litigation against any
17 entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 that this implementation of Go or any code incorporated within this
19 implementation of Go constitutes direct or contributory patent
20 infringement, or inducement of patent infringement, then any patent
21 rights granted to you under this License for this implementation of Go
22 shall terminate as of the date such litigation is filed.