leveros: github.com/leveros/leveros/core Index | Files

package core

import "github.com/leveros/leveros/core"

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

Package Files

core.go leverjson.go leverrpc.go leverrpc.pb.go leverurl.go

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")
)

func IsAdmin Uses

func IsAdmin(leverURL *LeverURL) bool

IsAdmin returns true iff the env + service represent the admin service.

func IsInternalEnvironment Uses

func IsInternalEnvironment(environment string) bool

IsInternalEnvironment returns true iff the provided environment is part of the same Lever deployment (RPCs can be routed internally).

func RegisterLeverRPCServer Uses

func RegisterLeverRPCServer(s *grpc.Server, srv LeverRPCServer)

type JSON Uses

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 Uses

func (*JSON) Descriptor() ([]byte, []int)

func (*JSON) GetJsonArray Uses

func (m *JSON) GetJsonArray() *JSONArray

func (*JSON) GetJsonBool Uses

func (m *JSON) GetJsonBool() bool

func (*JSON) GetJsonNumber Uses

func (m *JSON) GetJsonNumber() float64

func (*JSON) GetJsonObject Uses

func (m *JSON) GetJsonObject() *JSONObject

func (*JSON) GetJsonString Uses

func (m *JSON) GetJsonString() string

func (*JSON) GetJsonValueOneof Uses

func (m *JSON) GetJsonValueOneof() isJSON_JsonValueOneof

func (*JSON) ProtoMessage Uses

func (*JSON) ProtoMessage()

func (*JSON) Reset Uses

func (m *JSON) Reset()

func (*JSON) String Uses

func (m *JSON) String() string

func (*JSON) XXX_OneofFuncs Uses

func (*JSON) 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 JSONArray Uses

type JSONArray struct {
    Element []*JSON `protobuf:"bytes,1,rep,name=element" json:"element,omitempty"`
}

func (*JSONArray) Descriptor Uses

func (*JSONArray) Descriptor() ([]byte, []int)

func (*JSONArray) GetElement Uses

func (m *JSONArray) GetElement() []*JSON

func (*JSONArray) ProtoMessage Uses

func (*JSONArray) ProtoMessage()

func (*JSONArray) Reset Uses

func (m *JSONArray) Reset()

func (*JSONArray) String Uses

func (m *JSONArray) String() string

type JSONObject Uses

type JSONObject struct {
    Property []*JSONProperty `protobuf:"bytes,1,rep,name=property" json:"property,omitempty"`
}

func (*JSONObject) Descriptor Uses

func (*JSONObject) Descriptor() ([]byte, []int)

func (*JSONObject) GetProperty Uses

func (m *JSONObject) GetProperty() []*JSONProperty

func (*JSONObject) ProtoMessage Uses

func (*JSONObject) ProtoMessage()

func (*JSONObject) Reset Uses

func (m *JSONObject) Reset()

func (*JSONObject) String Uses

func (m *JSONObject) String() string

type JSONProperty Uses

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 Uses

func (*JSONProperty) Descriptor() ([]byte, []int)

func (*JSONProperty) GetValue Uses

func (m *JSONProperty) GetValue() *JSON

func (*JSONProperty) ProtoMessage Uses

func (*JSONProperty) ProtoMessage()

func (*JSONProperty) Reset Uses

func (m *JSONProperty) Reset()

func (*JSONProperty) String Uses

func (m *JSONProperty) String() string

type JSON_JsonArray Uses

type JSON_JsonArray struct {
    JsonArray *JSONArray `protobuf:"bytes,5,opt,name=json_array,json=jsonArray,oneof"`
}

type JSON_JsonBool Uses

type JSON_JsonBool struct {
    JsonBool bool `protobuf:"varint,3,opt,name=json_bool,json=jsonBool,oneof"`
}

type JSON_JsonNumber Uses

type JSON_JsonNumber struct {
    JsonNumber float64 `protobuf:"fixed64,2,opt,name=json_number,json=jsonNumber,oneof"`
}

type JSON_JsonObject Uses

type JSON_JsonObject struct {
    JsonObject *JSONObject `protobuf:"bytes,4,opt,name=json_object,json=jsonObject,oneof"`
}

type JSON_JsonString Uses

type JSON_JsonString struct {
    JsonString string `protobuf:"bytes,1,opt,name=json_string,json=jsonString,oneof"`
}

type LeverConfig Uses

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 Uses

func ReadLeverConfig(dirPath string) (*LeverConfig, error)

ReadLeverConfig reads lever.json from the provided directory.

func (*LeverConfig) GeneralEntryPoint Uses

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 Uses

func (leverConfig *LeverConfig) Write(dirPath string) error

Write writes lever.json to provied directory.

type LeverRPCClient Uses

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 Uses

func NewLeverRPCClient(cc *grpc.ClientConn) LeverRPCClient

type LeverRPCServer Uses

type LeverRPCServer interface {
    HandleRPC(context.Context, *RPC) (*RPCReply, error)
    HandleStreamingRPC(LeverRPC_HandleStreamingRPCServer) error
}

type LeverRPC_HandleStreamingRPCClient Uses

type LeverRPC_HandleStreamingRPCClient interface {
    Send(*StreamMessage) error
    Recv() (*StreamMessage, error)
    grpc.ClientStream
}

func SendStreamingLeverRPC Uses

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 Uses

type LeverRPC_HandleStreamingRPCServer interface {
    Send(*StreamMessage) error
    Recv() (*StreamMessage, error)
    grpc.ServerStream
}

type LeverURL Uses

type LeverURL struct {
    Environment string
    Service     string
    Resource    string
    Method      string
}

LeverURL holds information about a Lever RPC destination.

func ParseLeverURL Uses

func ParseLeverURL(urlStr string) (*LeverURL, error)

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

func (*LeverURL) String Uses

func (leverURL *LeverURL) String() string

String returns the URL string representation of the LeverURL. If Environment is "" then the URL will be relative.

type RPC Uses

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 Uses

func (*RPC) Descriptor() ([]byte, []int)

func (*RPC) GetArgs Uses

func (m *RPC) GetArgs() *JSONArray

func (*RPC) GetArgsOneof Uses

func (m *RPC) GetArgsOneof() isRPC_ArgsOneof

func (*RPC) GetByteArgs Uses

func (m *RPC) GetByteArgs() []byte

func (*RPC) ProtoMessage Uses

func (*RPC) ProtoMessage()

func (*RPC) Reset Uses

func (m *RPC) Reset()

func (*RPC) String Uses

func (m *RPC) String() string

func (*RPC) XXX_OneofFuncs Uses

func (*RPC) 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 RPCReply Uses

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 Uses

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 Uses

func (*RPCReply) Descriptor() ([]byte, []int)

func (*RPCReply) GetByteError Uses

func (m *RPCReply) GetByteError() []byte

func (*RPCReply) GetByteResult Uses

func (m *RPCReply) GetByteResult() []byte

func (*RPCReply) GetError Uses

func (m *RPCReply) GetError() *JSON

func (*RPCReply) GetResult Uses

func (m *RPCReply) GetResult() *JSON

func (*RPCReply) GetResultOneof Uses

func (m *RPCReply) GetResultOneof() isRPCReply_ResultOneof

func (*RPCReply) ProtoMessage Uses

func (*RPCReply) ProtoMessage()

func (*RPCReply) Reset Uses

func (m *RPCReply) Reset()

func (*RPCReply) String Uses

func (m *RPCReply) String() string

func (*RPCReply) XXX_OneofFuncs Uses

func (*RPCReply) 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 RPCReply_ByteError Uses

type RPCReply_ByteError struct {
    ByteError []byte `protobuf:"bytes,4,opt,name=byte_error,json=byteError,proto3,oneof"`
}

type RPCReply_ByteResult Uses

type RPCReply_ByteResult struct {
    ByteResult []byte `protobuf:"bytes,2,opt,name=byte_result,json=byteResult,proto3,oneof"`
}

type RPCReply_Error Uses

type RPCReply_Error struct {
    Error *JSON `protobuf:"bytes,3,opt,name=error,oneof"`
}

type RPCReply_Result Uses

type RPCReply_Result struct {
    Result *JSON `protobuf:"bytes,1,opt,name=result,oneof"`
}

type RPC_Args Uses

type RPC_Args struct {
    Args *JSONArray `protobuf:"bytes,1,opt,name=args,oneof"`
}

type RPC_ByteArgs Uses

type RPC_ByteArgs struct {
    ByteArgs []byte `protobuf:"bytes,2,opt,name=byte_args,json=byteArgs,proto3,oneof"`
}

type StreamMessage Uses

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 Uses

func (*StreamMessage) Descriptor() ([]byte, []int)

func (*StreamMessage) GetByteError Uses

func (m *StreamMessage) GetByteError() []byte

func (*StreamMessage) GetByteMessage Uses

func (m *StreamMessage) GetByteMessage() []byte

func (*StreamMessage) GetError Uses

func (m *StreamMessage) GetError() *JSON

func (*StreamMessage) GetMessage Uses

func (m *StreamMessage) GetMessage() *JSON

func (*StreamMessage) GetMessageOneof Uses

func (m *StreamMessage) GetMessageOneof() isStreamMessage_MessageOneof

func (*StreamMessage) GetRpc Uses

func (m *StreamMessage) GetRpc() *RPC

func (*StreamMessage) ProtoMessage Uses

func (*StreamMessage) ProtoMessage()

func (*StreamMessage) Reset Uses

func (m *StreamMessage) Reset()

func (*StreamMessage) String Uses

func (m *StreamMessage) String() string

func (*StreamMessage) XXX_OneofFuncs Uses

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 Uses

type StreamMessage_ByteError struct {
    ByteError []byte `protobuf:"bytes,5,opt,name=byte_error,json=byteError,proto3,oneof"`
}

type StreamMessage_ByteMessage Uses

type StreamMessage_ByteMessage struct {
    ByteMessage []byte `protobuf:"bytes,3,opt,name=byte_message,json=byteMessage,proto3,oneof"`
}

type StreamMessage_Error Uses

type StreamMessage_Error struct {
    Error *JSON `protobuf:"bytes,4,opt,name=error,oneof"`
}

type StreamMessage_Message Uses

type StreamMessage_Message struct {
    Message *JSON `protobuf:"bytes,2,opt,name=message,oneof"`
}

type StreamMessage_Rpc Uses

type StreamMessage_Rpc struct {
    Rpc *RPC `protobuf:"bytes,1,opt,name=rpc,oneof"`
}

Package core imports 12 packages (graph) and is imported by 50 packages. Updated 2016-07-23. Refresh now. Tools for package owners.