Skip to content

Instantly share code, notes, and snippets.

View jhump's full-sized avatar

Joshua Humphries jhump

View GitHub Profile
@jhump
jhump / service.proto
Created June 29, 2020 15:06
Example using custom options
syntax = "proto3";
package fs.operations.v1;
import "fs/auth/grpcauth.proto";
import "fs/operations/ops.proto";
import "google/api/annotations.proto";
service Operations {
rpc GetOperationStatus (OperationId) returns (OperationStatus) {
@jhump
jhump / options.proto
Created June 29, 2020 15:06
Example descriptor options
syntax = "proto3";
package fs.auth;
import "fs/shared/flags/flags.proto";
import "google/protobuf/descriptor.proto";
extend google.protobuf.MethodOptions {
repeated fs.flags.Flag required_flags = 20000;
@jhump
jhump / admin.proto
Created June 29, 2020 14:23
Example admin grpc service interface
// This is an example of a gRPC service that has admin endpoints for managing
// various aspects of configuration for FullStory customers.
syntax = "proto3";
package fullstory.orgs;
import "google/protobuf/empty.proto";
service Admin {
// Retrieves the details of the request org.
@jhump
jhump / example.go
Last active June 29, 2020 14:20
Example using grpcui standalone package
//----------------------------
// Start up our gRPC server
//----------------------------
svr := grpc.NewServer()
// we need the reflection service, to power the UI
reflection.Register(svr)
// ...
// register our gRPC services and then start up the server in a goroutine
@jhump
jhump / foo.pb.go
Last active June 24, 2020 03:37
Example of using grpcui standalone package
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.24.0-devel
// protoc v3.11.3
// source: foo.proto
package main
import (
context "context"
@jhump
jhump / GrpcCustomOptionsExample.java
Created July 19, 2017 14:24
grpc-java interceptor with options
import com.google.protobuf.Descriptors.MethodDescriptor;
import com.google.protobuf.Descriptors.ServiceDescriptor;
import com.google.protobuf.DescriptorProtos.MethodOptions;
import io.grpc.BindableService;
import io.grpc.Metadata;
import io.grpc.Server;
import io.grpc.ServerBuilder;
import io.grpc.ServerCall;
import io.grpc.ServerCallHandler;
@jhump
jhump / PriorityBlockingQueue2.java
Created March 2, 2017 01:49
PriorityBlockingQueue with O(n) implementation of removeIf
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Random;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.locks.Lock;