[Sorry, I accidentally hit send before I had finished typing . .] Is there any way to achieve what I'm looking for? Or is this just beyond the scope of ValueProvider and templates?
On Thu, May 3, 2018 at 5:36 PM, Frank Yellin <[email protected]> wrote: > I'm attempting to create a dataflow template, and within the template have > a variable > ValueProvider<DateTime> now > such that now is the time the dataflow is started, note the time that the > template was created. > > My first attempt was > ValueProvider<DateTime> now = StaticValueProvider.of(DateTim > e.now(DateTimeZone.UTC)); > > My second attempt was > > public interface MyOptions extends PipelineOptions, > DataflowPipelineOptions { > @Description("Now") > @Default.InstanceFactory(GetNow.class) > ValueProvider<DateTime> getNow(); > void setNow(ValueProvider<DateTime> value); > } > > static class GetNow implements DefaultValueFactory<DateTime> { > @Override > public DateTime create(PipelineOptions options) { > return DateTime.now(DateTimeZone.UTC); > } > } > > ValueProvider<DateTime> now = options.getNow() > > My final attempt was: > > ValueProvider<SerializableFunction<Void, DateTime>> nowFn = > StaticValueProvider.of(x -> DateTime.now(DateTimeZone.UTC)); > > ValueProvider<DateTime> now = NestedValueProvider.of(nowFn, x -> > x.apply(null)); > > > > In every case, it was clear that "now" was being set to template-creation > time rather than actual runtime. > > I note that the documentation talks about a RuntimeValueProvider, but > there is no user-visible constructor for this. > > > >
