resources: Specify defaults for the MetaParams

When creating new resources, we didn't specify the defaults, which for
the limit metaparam caused invalid resources by default. It would be
nice to change the limit param to have the 1/X (reciprocal) as the
default, although the problem with that is that (1) it is illogical, and
(2) it's not clear if the precision for the common cases is enough.

If someone wants to investigate this further, please do! Zero value
structs are definitely more useful! In any case, we can now specify the
default. It's not entirely obvious to me if this is the best way to do
it, or if there is a superior method.
This commit is contained in:
James Shubin
2017-02-16 00:47:22 -05:00
parent 2647d09b8f
commit b7948c7f40
13 changed files with 54 additions and 10 deletions

View File

@@ -54,7 +54,11 @@ type MsgUID struct {
// Default returns some sensible defaults for this resource.
func (obj *MsgRes) Default() Res {
return &MsgRes{}
return &MsgRes{
BaseRes: BaseRes{
MetaParams: DefaultMetaParams, // force a default
},
}
}
// Validate the params that are passed to MsgRes.