Documentation ¶
Overview ¶
Package core provides common utilities to be used throughout various Lever binaries and libraries. These utilities are very specific to Lever.
Package core is a generated protocol buffer package.
It is generated from these files:
leverrpc.proto
It has these top-level messages:
RPC StreamMessage RPCReply JSON JSONObject JSONArray JSONProperty
Index ¶
- Constants
- Variables
- func IsAdmin(leverURL *LeverURL) bool
- func IsInternalEnvironment(environment string) bool
- func RegisterLeverRPCServer(s *grpc.Server, srv LeverRPCServer)
- type JSON
- func (*JSON) Descriptor() ([]byte, []int)
- func (m *JSON) GetJsonArray() *JSONArray
- func (m *JSON) GetJsonBool() bool
- func (m *JSON) GetJsonNumber() float64
- func (m *JSON) GetJsonObject() *JSONObject
- func (m *JSON) GetJsonString() string
- func (m *JSON) GetJsonValueOneof() isJSON_JsonValueOneof
- func (*JSON) ProtoMessage()
- func (m *JSON) Reset()
- func (m *JSON) String() string
- func (*JSON) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type JSONArray
- type JSONObject
- type JSONProperty
- type JSON_JsonArray
- type JSON_JsonBool
- type JSON_JsonNumber
- type JSON_JsonObject
- type JSON_JsonString
- type LeverConfig
- type LeverRPCClient
- type LeverRPCServer
- type LeverRPC_HandleStreamingRPCClient
- type LeverRPC_HandleStreamingRPCServer
- type LeverURL
- type RPC
- func (*RPC) Descriptor() ([]byte, []int)
- func (m *RPC) GetArgs() *JSONArray
- func (m *RPC) GetArgsOneof() isRPC_ArgsOneof
- func (m *RPC) GetByteArgs() []byte
- func (*RPC) ProtoMessage()
- func (m *RPC) Reset()
- func (m *RPC) String() string
- func (*RPC) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type RPCReply
- func (*RPCReply) Descriptor() ([]byte, []int)
- func (m *RPCReply) GetByteError() []byte
- func (m *RPCReply) GetByteResult() []byte
- func (m *RPCReply) GetError() *JSON
- func (m *RPCReply) GetResult() *JSON
- func (m *RPCReply) GetResultOneof() isRPCReply_ResultOneof
- func (*RPCReply) ProtoMessage()
- func (m *RPCReply) Reset()
- func (m *RPCReply) String() string
- func (*RPCReply) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type RPCReply_ByteError
- type RPCReply_ByteResult
- type RPCReply_Error
- type RPCReply_Result
- type RPC_Args
- type RPC_ByteArgs
- type StreamMessage
- func (*StreamMessage) Descriptor() ([]byte, []int)
- func (m *StreamMessage) GetByteError() []byte
- func (m *StreamMessage) GetByteMessage() []byte
- func (m *StreamMessage) GetError() *JSON
- func (m *StreamMessage) GetMessage() *JSON
- func (m *StreamMessage) GetMessageOneof() isStreamMessage_MessageOneof
- func (m *StreamMessage) GetRpc() *RPC
- func (*StreamMessage) ProtoMessage()
- func (m *StreamMessage) Reset()
- func (m *StreamMessage) String() string
- func (*StreamMessage) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type StreamMessage_ByteError
- type StreamMessage_ByteMessage
- type StreamMessage_Error
- type StreamMessage_Message
- type StreamMessage_Rpc
Constants ¶
const ( // RPCMethodHandler represents the gRPC method handling Lever RPCs. RPCMethodHandler = "HandleRPC" // StreamingRPCMethodHandler represents the gRPC method handling streaming // Lever RPCs. StreamingRPCMethodHandler = "HandleStreamingRPC" )
const PackageName = "core"
PackageName is the name of this package.
Variables ¶
var ( // InstanceListenPortFlag is the port Lever instances listen on for // Lever RPCs. InstanceListenPortFlag = config.DeclareString( PackageName, "instanceListenPort", "3837") // InternalEnvironmentSuffixFlag represents the ending of the environment // host name to which RPCs can be routed to directly (via internal proxies). InternalEnvironmentSuffixFlag = config.DeclareString( PackageName, "internalEnvSufix", ".lever") // DefaultDevAliasFlag is the actual address of the default Lever // environment used for local development. DefaultDevAliasFlag = config.DeclareString( PackageName, "defaultDevAlias", getDefaultLeverOSIPPort()) // DefaultDevEnvFlag is the default Lever environment used for local // development. DefaultDevEnvFlag = config.DeclareString( PackageName, "defaultDevEnv", "dev.lever") // AdminEnvFlag is the admin Lever environment. AdminEnvFlag = config.DeclareString( PackageName, "adminEnv", "admin.lever") )
Functions ¶
func IsInternalEnvironment ¶
IsInternalEnvironment returns true iff the provided environment is part of the same Lever deployment (RPCs can be routed internally).
func RegisterLeverRPCServer ¶
func RegisterLeverRPCServer(s *grpc.Server, srv LeverRPCServer)
Types ¶
type JSON ¶
type JSON struct { // Note: If none are set then the value is null. // // Types that are valid to be assigned to JsonValueOneof: // *JSON_JsonString // *JSON_JsonNumber // *JSON_JsonBool // *JSON_JsonObject // *JSON_JsonArray JsonValueOneof isJSON_JsonValueOneof `protobuf_oneof:"json_value_oneof"` }
JSON represents a JSON-like value, which is represented as a proto message.
func (*JSON) Descriptor ¶
func (*JSON) GetJsonArray ¶
func (*JSON) GetJsonBool ¶
func (*JSON) GetJsonNumber ¶
func (*JSON) GetJsonObject ¶
func (m *JSON) GetJsonObject() *JSONObject
func (*JSON) GetJsonString ¶
func (*JSON) GetJsonValueOneof ¶
func (m *JSON) GetJsonValueOneof() isJSON_JsonValueOneof
func (*JSON) ProtoMessage ¶
func (*JSON) ProtoMessage()
type JSONArray ¶
type JSONArray struct {
Element []*JSON `protobuf:"bytes,1,rep,name=element" json:"element,omitempty"`
}
func (*JSONArray) Descriptor ¶
func (*JSONArray) GetElement ¶
func (*JSONArray) ProtoMessage ¶
func (*JSONArray) ProtoMessage()
type JSONObject ¶
type JSONObject struct {
Property []*JSONProperty `protobuf:"bytes,1,rep,name=property" json:"property,omitempty"`
}
func (*JSONObject) Descriptor ¶
func (*JSONObject) Descriptor() ([]byte, []int)
func (*JSONObject) GetProperty ¶
func (m *JSONObject) GetProperty() []*JSONProperty
func (*JSONObject) ProtoMessage ¶
func (*JSONObject) ProtoMessage()
func (*JSONObject) Reset ¶
func (m *JSONObject) Reset()
func (*JSONObject) String ¶
func (m *JSONObject) String() string
type JSONProperty ¶
type JSONProperty struct { Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` Value *JSON `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` }
func (*JSONProperty) Descriptor ¶
func (*JSONProperty) Descriptor() ([]byte, []int)
func (*JSONProperty) GetValue ¶
func (m *JSONProperty) GetValue() *JSON
func (*JSONProperty) ProtoMessage ¶
func (*JSONProperty) ProtoMessage()
func (*JSONProperty) Reset ¶
func (m *JSONProperty) Reset()
func (*JSONProperty) String ¶
func (m *JSONProperty) String() string
type JSON_JsonArray ¶
type JSON_JsonArray struct {
JsonArray *JSONArray `protobuf:"bytes,5,opt,name=json_array,json=jsonArray,oneof"`
}
type JSON_JsonBool ¶
type JSON_JsonBool struct {
JsonBool bool `protobuf:"varint,3,opt,name=json_bool,json=jsonBool,oneof"`
}
type JSON_JsonNumber ¶
type JSON_JsonNumber struct {
JsonNumber float64 `protobuf:"fixed64,2,opt,name=json_number,json=jsonNumber,oneof"`
}
type JSON_JsonObject ¶
type JSON_JsonObject struct {
JsonObject *JSONObject `protobuf:"bytes,4,opt,name=json_object,json=jsonObject,oneof"`
}
type JSON_JsonString ¶
type JSON_JsonString struct {
JsonString string `protobuf:"bytes,1,opt,name=json_string,json=jsonString,oneof"`
}
type LeverConfig ¶
type LeverConfig struct { Service string `json:"name"` Description string `json:"description,omitempty"` // Only one may be specified. EntryPoint []string `json:"entry,omitempty"` JSEntryPoint string `json:"jsEntry,omitempty"` IsPrivate bool `json:"private,omitempty"` MaxInstanceLoad float64 `json:"maxInstanceLoad,omitempty"` MinInstances int `json:"minInstances,omitempty"` InstanceMemoryMB int `json:"ram,omitempty"` // TODO: Future: Allow cust to add own config which can be read from within // the service. Changing just these would not cause service restart. // Think feature flags. CustConfig map[string]interface{} `json:"config,omitempty"` }
LeverConfig is the representation of the contents of lever.json.
func ReadLeverConfig ¶
func ReadLeverConfig(dirPath string) (*LeverConfig, error)
ReadLeverConfig reads lever.json from the provided directory.
func (*LeverConfig) GeneralEntryPoint ¶
func (leverConfig *LeverConfig) GeneralEntryPoint() []string
GeneralEntryPoint returns the entry point specified by the config. (Whether that is specified via entry, goEntry etc).
func (*LeverConfig) Write ¶
func (leverConfig *LeverConfig) Write(dirPath string) error
Write writes lever.json to provied directory.
type LeverRPCClient ¶
type LeverRPCClient interface { HandleRPC(ctx context.Context, in *RPC, opts ...grpc.CallOption) (*RPCReply, error) HandleStreamingRPC(ctx context.Context, opts ...grpc.CallOption) (LeverRPC_HandleStreamingRPCClient, error) }
func NewLeverRPCClient ¶
func NewLeverRPCClient(cc *grpc.ClientConn) LeverRPCClient
type LeverRPCServer ¶
type LeverRPC_HandleStreamingRPCClient ¶
type LeverRPC_HandleStreamingRPCClient interface { Send(*StreamMessage) error Recv() (*StreamMessage, error) grpc.ClientStream }
func SendStreamingLeverRPC ¶
func SendStreamingLeverRPC( conn *grpc.ClientConn, ctx context.Context, leverURL *LeverURL, opts ...grpc.CallOption) ( LeverRPC_HandleStreamingRPCClient, error)
SendStreamingLeverRPC sends a Lever streaming RPC to a certain resource within the service being contacted.
type LeverRPC_HandleStreamingRPCServer ¶
type LeverRPC_HandleStreamingRPCServer interface { Send(*StreamMessage) error Recv() (*StreamMessage, error) grpc.ServerStream }
type LeverURL ¶
LeverURL holds information about a Lever RPC destination.
func ParseLeverURL ¶
ParseLeverURL parses a URL into a LeverURL. Formats accepted are
Absolute:
lever://<host>[:<port>]/<service>[/<resource>]/<method>
or
Relative (within same environment):
/<service>[/<resource>]/method
type RPC ¶
type RPC struct { // Types that are valid to be assigned to ArgsOneof: // *RPC_Args // *RPC_ByteArgs ArgsOneof isRPC_ArgsOneof `protobuf_oneof:"args_oneof"` }
RPC is the message used to invoke a Lever service's method.
func (*RPC) Descriptor ¶
func (*RPC) GetArgsOneof ¶
func (m *RPC) GetArgsOneof() isRPC_ArgsOneof
func (*RPC) GetByteArgs ¶
func (*RPC) ProtoMessage ¶
func (*RPC) ProtoMessage()
type RPCReply ¶
type RPCReply struct { // Types that are valid to be assigned to ResultOneof: // *RPCReply_Result // *RPCReply_ByteResult // *RPCReply_Error // *RPCReply_ByteError ResultOneof isRPCReply_ResultOneof `protobuf_oneof:"result_oneof"` }
RPCReply is used as a return value for a Lever RPC method invokation.
func SendLeverRPC ¶
func SendLeverRPC( conn *grpc.ClientConn, ctx context.Context, leverURL *LeverURL, in *RPC, opts ...grpc.CallOption) (*RPCReply, error)
SendLeverRPC sends a Lever RPC to a certain resource within the service being contacted.
func (*RPCReply) Descriptor ¶
func (*RPCReply) GetByteError ¶
func (*RPCReply) GetByteResult ¶
func (*RPCReply) GetResultOneof ¶
func (m *RPCReply) GetResultOneof() isRPCReply_ResultOneof
func (*RPCReply) ProtoMessage ¶
func (*RPCReply) ProtoMessage()
type RPCReply_ByteError ¶
type RPCReply_ByteError struct {
ByteError []byte `protobuf:"bytes,4,opt,name=byte_error,json=byteError,proto3,oneof"`
}
type RPCReply_ByteResult ¶
type RPCReply_ByteResult struct {
ByteResult []byte `protobuf:"bytes,2,opt,name=byte_result,json=byteResult,proto3,oneof"`
}
type RPCReply_Error ¶
type RPCReply_Error struct {
Error *JSON `protobuf:"bytes,3,opt,name=error,oneof"`
}
type RPCReply_Result ¶
type RPCReply_Result struct {
Result *JSON `protobuf:"bytes,1,opt,name=result,oneof"`
}
type RPC_ByteArgs ¶
type RPC_ByteArgs struct {
ByteArgs []byte `protobuf:"bytes,2,opt,name=byte_args,json=byteArgs,proto3,oneof"`
}
type StreamMessage ¶
type StreamMessage struct { // Note that the invokation details (rpc field) are part of the very first // message sent by the client. It is an error for any other message to have // that field set. // Also, the very first message sent by the server must be an empty // message. This is a workaround for some reverse-proxies which do funny // things if there's no data frame. // // Types that are valid to be assigned to MessageOneof: // *StreamMessage_Rpc // *StreamMessage_Message // *StreamMessage_ByteMessage // *StreamMessage_Error // *StreamMessage_ByteError MessageOneof isStreamMessage_MessageOneof `protobuf_oneof:"message_oneof"` }
StreamMessage represents individual messages sent in a streaming RPC call. These may be either sent or received.
func (*StreamMessage) Descriptor ¶
func (*StreamMessage) Descriptor() ([]byte, []int)
func (*StreamMessage) GetByteError ¶
func (m *StreamMessage) GetByteError() []byte
func (*StreamMessage) GetByteMessage ¶
func (m *StreamMessage) GetByteMessage() []byte
func (*StreamMessage) GetError ¶
func (m *StreamMessage) GetError() *JSON
func (*StreamMessage) GetMessage ¶
func (m *StreamMessage) GetMessage() *JSON
func (*StreamMessage) GetMessageOneof ¶
func (m *StreamMessage) GetMessageOneof() isStreamMessage_MessageOneof
func (*StreamMessage) GetRpc ¶
func (m *StreamMessage) GetRpc() *RPC
func (*StreamMessage) ProtoMessage ¶
func (*StreamMessage) ProtoMessage()
func (*StreamMessage) Reset ¶
func (m *StreamMessage) Reset()
func (*StreamMessage) String ¶
func (m *StreamMessage) String() string
func (*StreamMessage) XXX_OneofFuncs ¶
func (*StreamMessage) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})
XXX_OneofFuncs is for the internal use of the proto package.
type StreamMessage_ByteError ¶
type StreamMessage_ByteError struct {
ByteError []byte `protobuf:"bytes,5,opt,name=byte_error,json=byteError,proto3,oneof"`
}
type StreamMessage_ByteMessage ¶
type StreamMessage_ByteMessage struct {
ByteMessage []byte `protobuf:"bytes,3,opt,name=byte_message,json=byteMessage,proto3,oneof"`
}
type StreamMessage_Error ¶
type StreamMessage_Error struct {
Error *JSON `protobuf:"bytes,4,opt,name=error,oneof"`
}
type StreamMessage_Message ¶
type StreamMessage_Message struct {
Message *JSON `protobuf:"bytes,2,opt,name=message,oneof"`
}
type StreamMessage_Rpc ¶
type StreamMessage_Rpc struct {
Rpc *RPC `protobuf:"bytes,1,opt,name=rpc,oneof"`
}