nstream.reflect.ReflectKernel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nstream-reflect Show documentation
Show all versions of nstream-reflect Show documentation
Web Agent introspection runtime
// Copyright 2015-2024 Nstream, inc.
//
// Licensed under the Redis Source Available License 2.0 (RSALv2) Agreement;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://redis.com/legal/rsalv2-agreement/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package nstream.reflect;
import swim.kernel.KernelProxy;
import swim.structure.Value;
import swim.system.EdgeAddress;
import swim.system.EdgeBinding;
public class ReflectKernel extends KernelProxy {
final double kernelPriority;
public ReflectKernel(double kernelPriority) {
this.kernelPriority = kernelPriority;
}
public ReflectKernel() {
this(KERNEL_PRIORITY);
}
@Override
public final double kernelPriority() {
return this.kernelPriority;
}
@Override
public EdgeBinding injectEdge(EdgeAddress edgeAddress, EdgeBinding edge) {
return new MetaEdge(super.injectEdge(edgeAddress, edge));
}
private static final double KERNEL_PRIORITY = 2.0;
public static ReflectKernel fromValue(Value moduleConfig) {
final Value header = moduleConfig.getAttr("kernel");
final String kernelClassName = header.get("class").stringValue(null);
if (kernelClassName == null || ReflectKernel.class.getName().equals(kernelClassName)) {
final double kernelPriority = header.get("priority").doubleValue(KERNEL_PRIORITY);
return new ReflectKernel(kernelPriority);
}
return null;
}
}