diff --git a/remote/context.go b/remote/context.go new file mode 100644 index 00000000..19eeb895 --- /dev/null +++ b/remote/context.go @@ -0,0 +1,31 @@ +package remote + +import ( + "code.google.com/p/go.net/context" +) + +const reqkey = "remote" + +// NewContext returns a Context whose Value method returns +// the applications Remote instance. +func NewContext(parent context.Context, v Remote) context.Context { + return &wrapper{parent, v} +} + +type wrapper struct { + context.Context + v Remote +} + +// Value returns the named key from the context. +func (c *wrapper) Value(key interface{}) interface{} { + if key == reqkey { + return c.v + } + return c.Context.Value(key) +} + +// FromContext returns the Remote associated with this context. +func FromContext(c context.Context) Remote { + return c.Value(reqkey).(Remote) +} diff --git a/shared/database/postgres/1_init.sql b/shared/database/postgres/1_init.sql index d98f3699..c3e96371 100644 --- a/shared/database/postgres/1_init.sql +++ b/shared/database/postgres/1_init.sql @@ -112,7 +112,7 @@ CREATE TABLE IF NOT EXISTS logs ( ); CREATE TABLE IF NOT EXISTS nodes ( - node_id INTEGER PRIMARY KEY AUTOINCREMENT + node_id SERIAL PRIMARY KEY ,node_addr VARCHAR(1024) ,node_arch VARCHAR(50) ,node_cert BYTEA