ValueRes is a no-op resource that accepts a value normally or via send/recv and it sends it via send/recv as well. XXX: intermediate chained values being used for send/recv must have a temporary placeholder value set or we'll get an invalid value error. This can be fixed eventually when we expand t
| 50 | // be fixed eventually when we expand the resource API. See the Default method |
| 51 | // of this resource for more information. |
| 52 | type ValueRes struct { |
| 53 | // This is similar to the KV resource, but it makes sense not to merge. |
| 54 | |
| 55 | traits.Base // add the base methods without re-implementation |
| 56 | |
| 57 | //traits.Groupable // TODO: this is doable, but probably not very useful |
| 58 | traits.Sendable |
| 59 | traits.Recvable |
| 60 | |
| 61 | init *engine.Init |
| 62 | |
| 63 | // Any is an arbitrary value to store in this resource. It can also be |
| 64 | // sent via send/recv and received by the same mechanism as well. The |
| 65 | // received value overwrites this value for the lifetime of the |
| 66 | // resource. It is interface{} because it can hold any type. It has |
| 67 | // pointer because it is only set if an actual value exists. |
| 68 | Any *interface{} `lang:"any" yaml:"any"` |
| 69 | |
| 70 | // Store specifies that we should store this value locally in our cache, |
| 71 | // so that if we have a cold startup, that it comes back instantly, even |
| 72 | // before we might get the current value from send/recv. This does not |
| 73 | // override any value passed in directly as a field parameter. This is |
| 74 | // mostly useful if we're using the value.get() function, and we don't |
| 75 | // want an initial stale value for a subsequent run. Remember that |
| 76 | // functions run before resources do! |
| 77 | // |
| 78 | // At the moment, this is permanently enabled until someone has a good |
| 79 | // reason why we wouldn't want it on. |
| 80 | //Store bool |
| 81 | |
| 82 | cachedAny *interface{} |
| 83 | isSet bool |
| 84 | } |
| 85 | |
| 86 | // Default returns some sensible defaults for this resource. |
| 87 | func (obj *ValueRes) Default() engine.Res { |