use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.
the class HttpPushTransformer method execute.
@Override
public FlowableTransformer<DataItem, DataItem> execute(StreamScriptContext context, Optional<ImmutableMessage> current, ImmutableMessage param) {
ReactiveResolvedParameters resolved = parameters.resolve(context, current, param, metadata);
String name = resolved.paramString("name");
int parallel = resolved.optionalInteger("parallel").orElse(1);
HttpResource res = HttpResourceFactory.getInstance().getHttpResource(name);
return flow -> {
if (res == null) {
throw new NullPointerException("Missing http resource: " + name);
}
return flow.map(f -> f.message()).observeOn(Schedulers.io()).map(msg -> {
ReactiveResolvedParameters resInMsg = parameters.resolve(context, Optional.of(msg), ImmutableFactory.empty(), metadata);
String id = resInMsg.paramString("id");
String bucket = resInMsg.paramString("bucket");
String property = resInMsg.paramString("property");
Binary bin = (Binary) msg.columnValue(property);
return res.put(context.getTenant(), bucket, id, bin).map(e -> e.toMessage()).toFlowable();
}).flatMap(f -> f, parallel).map(DataItem::of);
};
}
Aggregations