io.odpf.stencil.client.StencilClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stencil Show documentation
Show all versions of stencil Show documentation
Library to pull latest proto descriptors from a remote server
The newest version!
package org.raystack.stencil.client;
import com.google.protobuf.Descriptors;
import com.google.protobuf.DynamicMessage;
import com.google.protobuf.InvalidProtocolBufferException;
import org.raystack.stencil.Parser;
import org.raystack.stencil.exception.StencilRuntimeException;
import java.io.Closeable;
import java.util.Map;
/**
* A client to get the protobuf descriptors and more information
*/
public interface StencilClient extends Closeable {
Descriptors.Descriptor get(String className);
default DynamicMessage parse(String className, byte[] data) throws InvalidProtocolBufferException {
Descriptors.Descriptor descriptor = get(className);
if (descriptor == null) {
throw new StencilRuntimeException(new Throwable(String.format("No Descriptors found for %s", className)));
}
return DynamicMessage.parseFrom(descriptor, data);
}
default Parser getParser(String className) {
return (data) -> parse(className, data);
}
Map getAll();
void refresh();
}