Documentation
¶
Overview ¶
Package rtctrl
Package rtctrl ¶
Package rtctrl ¶
Package rtctrl ¶
Package rtctrl ¶
Package rtctrl
Index ¶
- Constants
- func ConvertHTTPResponseToProxy(rsp *http.Response, reqInfo *RequestInfo)
- func ConvertProxyRequestToHTTP(reqInfo *RequestInfo) (request *http.Request, cancel func())
- func InitRtCtrlMetric() error
- func ListenerFromAddress(addr string, fileMode os.FileMode) (net.Listener, error)
- func StageName(stage rtCtrlInvokeStage) string
- func TryConnectAddress(addr string) error
- type CASOpType
- type Control
- type DispatchServerV2
- type DispatcherV2Options
- type InvocationInput
- type InvocationOutput
- type InvocationResponse
- type InvocationStatistic
- type InvokeHTTPRequest
- type InvokeHTTPResponse
- type InvokeRequest
- type InvokeResponse
- type LogStatStore
- type LogStatStoreParameter
- type MarkInput
- type MergedInput
- type NewRuntimeParameters
- type OccupyInput
- type ReportedRunnerInfo
- type RequestInfo
- func (info *RequestInfo) CleanInput()
- func (info *RequestInfo) CleanOutput()
- func (info *RequestInfo) InvokeDone()
- func (info *RequestInfo) InvokeReportDone()
- func (info *RequestInfo) InvokeResult(status RequestStatus, result string)
- func (info *RequestInfo) InvokeStart()
- func (info *RequestInfo) Notify()
- func (info *RequestInfo) SetInitTime(preInit, postInit int64)
- func (info *RequestInfo) SetLogStore(store LogStatStore)
- func (info *RequestInfo) StepDone(state rtCtrlInvokeStage)
- type RequestStatus
- type ResetInput
- type RetrieveInput
- type RollbackInput
- type RtCtrlInvokeMetric
- type RuntimeClient
- type RuntimeConfigOptions
- type RuntimeDispatcher
- type RuntimeInfo
- func (info *RuntimeInfo) CAS(opType CASOpType, args interface{}) (err error)
- func (info *RuntimeInfo) Invalidate()
- func (info *RuntimeInfo) InvokeDone(request *RequestInfo, signal bool)
- func (info *RuntimeInfo) InvokeFunc(request *RequestInfo, invokeReq *InvokeRequest) error
- func (info *RuntimeInfo) InvokeHTTPFunc(request *RequestInfo, invokeReq *InvokeHTTPRequest) error
- func (info *RuntimeInfo) IsRunnerDefunct(deadline time.Time) bool
- func (info *RuntimeInfo) RebootBegin()
- func (info *RuntimeInfo) RebootEnd()
- func (info *RuntimeInfo) RebootWait()
- func (info *RuntimeInfo) Release() error
- func (info *RuntimeInfo) SetCommitID(cm string)
- func (info *RuntimeInfo) SetInitTime(pre, post int64)
- func (info *RuntimeInfo) SetLoadTime(pre, post int64)
- func (info *RuntimeInfo) SetMarked(m bool)
- func (info *RuntimeInfo) SetMemorySize(mem uint64)
- func (info *RuntimeInfo) SetResource(mem uint64, cpu int64)
- func (info *RuntimeInfo) SetState(s RuntimeStateType)
- func (info *RuntimeInfo) SetUsed(m bool)
- func (info *RuntimeInfo) Wait(timeout int) bool
- type RuntimeInfoError
- type RuntimeManager
- func (m *RuntimeManager) CoolDownRuntime(runtime *RuntimeInfo) (recommend *api.ScaleDownRecommendation, err error)
- func (m *RuntimeManager) DelRuntime(runtimeID string)
- func (m *RuntimeManager) FindWarmRuntime(req *InvocationInput) *RuntimeInfo
- func (m *RuntimeManager) GetRuntime(runtimeID string) (ri *RuntimeInfo, err error)
- func (m *RuntimeManager) IncreaseUsedResource(rs *api.Resource) bool
- func (m *RuntimeManager) NewRuntime(params *NewRuntimeParameters) *RuntimeInfo
- func (m *RuntimeManager) OccupyColdRuntime(req *InvocationInput) (ri *RuntimeInfo, recommend *api.ScaleUpRecommendation)
- func (m *RuntimeManager) ReleaseMarkedResource(rs *api.Resource) bool
- func (m *RuntimeManager) ReleaseUsedResource(rs *api.Resource) bool
- func (m *RuntimeManager) ResetRuntime(runtime *RuntimeInfo) (recommend *api.ScaleDownRecommendation, err error)
- func (m *RuntimeManager) ResourceStatistics() (resource *api.ServiceResource)
- func (m *RuntimeManager) RuntimeList() []*RuntimeInfo
- func (m *RuntimeManager) RuntimeStatistics() (cold, inUse, all int)
- func (m *RuntimeManager) String() string
- func (m *RuntimeManager) SyncResource(resource *api.FuncletResource) bool
- func (m *RuntimeManager) SyncRuntimeResource(ID string, resource *api.Resource) (sync bool, err error)
- type RuntimeManagerParameters
- type RuntimeMatchError
- type RuntimeNoNeedToReset
- type RuntimeNotExist
- type RuntimeReleaseError
- type RuntimeStateType
- type RuntimeStateUnmatched
- type RuntimeSyncError
- type StatisticInfo
- type StopInput
- type UserLogType
Constants ¶
View Source
const ( ZeroByte byte = '\000' TabByte byte = '\t' LineByte byte = '\n' StdoutLog = 1 StderrLog = 2 )
View Source
const ( StageWaitRuntime rtCtrlInvokeStage = iota StageStartRecvLog StageInvokeFunc StageSendRequest StageRecvResponse StageInvokeDone StageInvokeReportDone StageStopRecvLog StageCleanup )
View Source
const (
RuntimeHTTPSock = ".runtime-http.sock"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertHTTPResponseToProxy ¶
func ConvertHTTPResponseToProxy(rsp *http.Response, reqInfo *RequestInfo)
func ConvertProxyRequestToHTTP ¶
func ConvertProxyRequestToHTTP(reqInfo *RequestInfo) (request *http.Request, cancel func())
func InitRtCtrlMetric ¶
func InitRtCtrlMetric() error
func ListenerFromAddress ¶
func TryConnectAddress ¶
Types ¶
type Control ¶
type Control interface {
InvokeFunction(input *InvocationInput) *InvocationOutput
}
type DispatchServerV2 ¶
type DispatchServerV2 struct {
// contains filtered or unexported fields
}
func NewDispatchServerV2 ¶
func NewDispatchServerV2(c *DispatcherV2Options, rtMap RuntimeDispatcher) *DispatchServerV2
func (*DispatchServerV2) ListenAndServe ¶
func (s *DispatchServerV2) ListenAndServe()
func (*DispatchServerV2) StartRecvLog ¶
func (s *DispatchServerV2) StartRecvLog(runtimeID, requestID string, store LogStatStore)
func (*DispatchServerV2) StopRecvLog ¶
func (s *DispatchServerV2) StopRecvLog(runtimeID, requestID string, store LogStatStore)
type DispatcherV2Options ¶
type DispatcherV2Options struct {
RuntimeServerAddress string
RunnerServerAddress string
UserLogFileDir string
UserLogType string
}
func NewDispatcherV2Options ¶
func NewDispatcherV2Options() *DispatcherV2Options
func (*DispatcherV2Options) AddFlags ¶
func (s *DispatcherV2Options) AddFlags(fs *pflag.FlagSet)
type InvocationInput ¶
type InvocationInput struct {
// runtime
Runtime *RuntimeInfo
// ExternalRequestID: external request ID
ExternalRequestID string
// RequestID: internal request ID
RequestID string
// User xxx
User *api.User
// The object for the Lambda function location.
Code *api.FunctionCodeLocation
// A complex type that describes function metadata.
Configuration *api.FunctionConfiguration
// log configuration
LogConfig *api.LogConfiguration
// define whether transfer request body as a stream
WithStreamMode bool
Request *api.InvokeProxyRequest
Response *api.InvokeProxyResponse
// Enable Metric
EnableMetrics bool
// IsLogTail
IsLogTail bool
Logger *logs.Logger
InvokeType string
TriggerType string
}
InvocationInput function call input param
type InvocationOutput ¶
type InvocationOutput struct {
Output *InvocationResponse
Statistic *InvocationStatistic
}
type InvocationResponse ¶
type InvocationResponse struct {
FuncResult string `json:"result,omitempty"`
LogMessage []string `json:"log"`
FuncError string `json:"errtype,omitempty"`
ErrorInfo string `json:"errinfo,omitempty"`
Response *api.InvokeProxyResponse
}
InvocationOutput function call output param
type InvocationStatistic ¶
type InvocationStatistic struct {
Statistic *StatisticInfo
Metric *RtCtrlInvokeMetric
}
type InvokeHTTPRequest ¶
type InvokeHTTPResponse ¶
type InvokeRequest ¶
type InvokeRequest struct {
RequestID string `json:"requestid"`
Version string `json:"version"`
AccessKeyID string `json:"accessKey"`
AccessKeySecret string `json:"secretKey"`
SecurityToken string `json:"securityToken"`
ClientContext string `json:"clientContext,omitempty"`
EventObject string `json:"eventObject,omitempty"`
}
type InvokeResponse ¶
type LogStatStore ¶
type LogStatStore interface {
Receiver() string
String() string
WriteStdLog(from int, buf []byte, eof bool) (int, error)
WriteFunctionLog(log string) error
WriteFunctionReportLog(log string, params *reportParameters) error
SetMemUsed(used int64)
LogFile() string
MemUsed() int64
LogDone(set bool) bool
Close() (string, error)
Wait()
}
type LogStatStoreParameter ¶
type MergedInput ¶
type MergedInput struct {
CommitID string
}
type NewRuntimeParameters ¶
type OccupyInput ¶
type ReportedRunnerInfo ¶
type RequestInfo ¶
type RequestInfo struct {
RequestID string
Runtime *RuntimeInfo
InvokeStartTimeNS int64
InvokeStartTimeMS int64
InitStartTimeMS int64
InitDoneTimeMS int64
InvokeDoneTimeMS int64
InvokeDurationMS time.Duration
BilledDurationMS time.Duration
MaxMemUsedBytes int64
MemorySpecSize int64
TriggerType string
Status RequestStatus
Input *InvocationInput
Output *InvocationOutput
SyncChannel chan struct{}
TimeoutChannel chan struct{} // timeout notification
// contains filtered or unexported fields
}
func NewRequestInfo ¶
func NewRequestInfo(requestID string, runtime *RuntimeInfo) *RequestInfo
func (*RequestInfo) CleanInput ¶
func (info *RequestInfo) CleanInput()
func (*RequestInfo) CleanOutput ¶
func (info *RequestInfo) CleanOutput()
func (*RequestInfo) InvokeDone ¶
func (info *RequestInfo) InvokeDone()
func (*RequestInfo) InvokeReportDone ¶
func (info *RequestInfo) InvokeReportDone()
func (*RequestInfo) InvokeResult ¶
func (info *RequestInfo) InvokeResult(status RequestStatus, result string)
func (*RequestInfo) InvokeStart ¶
func (info *RequestInfo) InvokeStart()
func (*RequestInfo) Notify ¶
func (info *RequestInfo) Notify()
func (*RequestInfo) SetInitTime ¶
func (info *RequestInfo) SetInitTime(preInit, postInit int64)
func (*RequestInfo) SetLogStore ¶
func (info *RequestInfo) SetLogStore(store LogStatStore)
func (*RequestInfo) StepDone ¶
func (info *RequestInfo) StepDone(state rtCtrlInvokeStage)
type RequestStatus ¶
type RequestStatus int
const ( StatusNormal RequestStatus = iota StatusRunning StatusSuccess StatusFailed StatusTimeout )
type ResetInput ¶
type RetrieveInput ¶
type RollbackInput ¶
type RollbackInput struct {
CommitID string
}
type RtCtrlInvokeMetric ¶
type RtCtrlInvokeMetric struct {
// contains filtered or unexported fields
}
func NewRtCtrlInvokeMetric ¶
func NewRtCtrlInvokeMetric(requestID string) *RtCtrlInvokeMetric
func (*RtCtrlInvokeMetric) MarshalLogObject ¶
func (i *RtCtrlInvokeMetric) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*RtCtrlInvokeMetric) ObserveAll ¶
func (r *RtCtrlInvokeMetric) ObserveAll()
func (*RtCtrlInvokeMetric) StepDone ¶
func (r *RtCtrlInvokeMetric) StepDone(stage rtCtrlInvokeStage)
type RuntimeClient ¶
type RuntimeClient struct {
// contains filtered or unexported fields
}
func NewRuntimeClient ¶
func NewRuntimeClient(c *RuntimeConfigOptions, s *DispatcherV2Options, rtMap RuntimeDispatcher) (rc *RuntimeClient, err error)
func (*RuntimeClient) InvokeFunc ¶
func (s *RuntimeClient) InvokeFunc(reqInfo *RequestInfo, input *InvocationInput) (err error)
func (*RuntimeClient) InvokeFunction ¶
func (s *RuntimeClient) InvokeFunction(input *InvocationInput) (output *InvocationOutput)
type RuntimeConfigOptions ¶
type RuntimeConfigOptions struct {
// Time to wait for runtime to connect (Cold Start)
// Units: seconds
WaitRuntimeAliveTimeout int
}
func NewRuntimeConfigOptions ¶
func NewRuntimeConfigOptions() *RuntimeConfigOptions
func (*RuntimeConfigOptions) AddFlags ¶
func (s *RuntimeConfigOptions) AddFlags(fs *pflag.FlagSet)
type RuntimeDispatcher ¶
type RuntimeDispatcher interface {
// runtime
RuntimeList() []*RuntimeInfo
GetRuntime(string) (*RuntimeInfo, error)
NewRuntime(*NewRuntimeParameters) *RuntimeInfo
OccupyColdRuntime(*InvocationInput) (*RuntimeInfo, *api.ScaleUpRecommendation)
FindWarmRuntime(*InvocationInput) *RuntimeInfo
CoolDownRuntime(*RuntimeInfo) (*api.ScaleDownRecommendation, error)
ResetRuntime(*RuntimeInfo) (*api.ScaleDownRecommendation, error)
// resource
IncreaseUsedResource(*api.Resource) bool
ReleaseUsedResource(*api.Resource) bool
ReleaseMarkedResource(rs *api.Resource) bool
SyncResource(*api.FuncletResource) bool
SyncRuntimeResource(string, *api.Resource) (bool, error)
// statistic
RuntimeStatistics() (cold, inUse, all int)
ResourceStatistics() *api.ServiceResource
}
type RuntimeInfo ¶
type RuntimeInfo struct {
RuntimeID string `json:"RuntimeID"`
// runtime state machine
State RuntimeStateType `json:"State"`
Used bool `json:"used"`
Marked bool `json:"marked"`
Abnormal bool `json:"abnormal"`
AbnormalTimes uint `json:"abnormalTimes"`
// runtime resource
Resource *api.Resource `json:"Resource"`
// Function meta
UserID string `json:"UserID"` // CFC User ID
CommitID string `json:"CommitID"`
MemorySize uint64 `json:"MemorySize"`
ConcurrentMode bool `json:"ConcurrentMode"`
DefaultConcurrentMode bool `json:"DefaultConcurrentMode"`
Concurrency uint64 `json:"Concurrency"`
WithStreamMode bool `json:"WithStreamMode"` // is http stream mode
WaitRuntimeAliveTimeout int `json:"WaitRuntimeAliveTimeout"`
// Statistics
PreLoadTimeMS int64 `json:"PreLoadTimeMS"`
PostLoadTimeMS int64 `json:"PostLoadTimeMS"`
PreInitTimeMS int64 `json:"PreInitTimeMS"`
PostInitTimeMS int64 `json:"PostInitTimeMS"`
AcceptReqCnt int64 `json:"AcceptReqCnt"`
RejectReqCnt int64 `json:"RejectReqCnt"`
LastLivenessTime time.Time `json:"LastLivenessTime"`
LastAccessTime time.Time `json:"LastAccessTime"`
LastResetTime time.Time `json:"LastResetTime"`
// contains filtered or unexported fields
}
func NewRuntimeInfo ¶
func NewRuntimeInfo(params *NewRuntimeParameters) *RuntimeInfo
func (*RuntimeInfo) CAS ¶
func (info *RuntimeInfo) CAS(opType CASOpType, args interface{}) (err error)
CAS check and set runtime info
func (*RuntimeInfo) Invalidate ¶
func (info *RuntimeInfo) Invalidate()
func (*RuntimeInfo) InvokeDone ¶
func (info *RuntimeInfo) InvokeDone(request *RequestInfo, signal bool)
func (*RuntimeInfo) InvokeFunc ¶
func (info *RuntimeInfo) InvokeFunc(request *RequestInfo, invokeReq *InvokeRequest) error
InvokeFunc
func (*RuntimeInfo) InvokeHTTPFunc ¶
func (info *RuntimeInfo) InvokeHTTPFunc(request *RequestInfo, invokeReq *InvokeHTTPRequest) error
InvokeFunc
func (*RuntimeInfo) IsRunnerDefunct ¶
func (info *RuntimeInfo) IsRunnerDefunct(deadline time.Time) bool
IsRunnerDefunct
func (*RuntimeInfo) RebootWait ¶
func (info *RuntimeInfo) RebootWait()
func (*RuntimeInfo) Release ¶
func (info *RuntimeInfo) Release() error
Release: release the occupation of runtime
func (*RuntimeInfo) SetCommitID ¶
func (info *RuntimeInfo) SetCommitID(cm string)
func (*RuntimeInfo) SetInitTime ¶
func (info *RuntimeInfo) SetInitTime(pre, post int64)
func (*RuntimeInfo) SetLoadTime ¶
func (info *RuntimeInfo) SetLoadTime(pre, post int64)
func (*RuntimeInfo) SetMarked ¶
func (info *RuntimeInfo) SetMarked(m bool)
func (*RuntimeInfo) SetMemorySize ¶
func (info *RuntimeInfo) SetMemorySize(mem uint64)
func (*RuntimeInfo) SetResource ¶
func (info *RuntimeInfo) SetResource(mem uint64, cpu int64)
func (*RuntimeInfo) SetState ¶
func (info *RuntimeInfo) SetState(s RuntimeStateType)
func (*RuntimeInfo) SetUsed ¶
func (info *RuntimeInfo) SetUsed(m bool)
type RuntimeInfoError ¶
type RuntimeInfoError struct {
RuntimeID string
}
RuntimeInfoError
func (RuntimeInfoError) Error ¶
func (e RuntimeInfoError) Error() string
type RuntimeManager ¶
type RuntimeManager struct {
MaxRuntimeIdle int
MaxRunnerDefunct int
MaxRunnerResetTimeout int
// contains filtered or unexported fields
}
func NewRuntimeManager ¶
func NewRuntimeManager(r *api.FuncletNodeInfo, params *RuntimeManagerParameters) *RuntimeManager
func (*RuntimeManager) CoolDownRuntime ¶
func (m *RuntimeManager) CoolDownRuntime(runtime *RuntimeInfo) (recommend *api.ScaleDownRecommendation, err error)
func (*RuntimeManager) DelRuntime ¶
func (m *RuntimeManager) DelRuntime(runtimeID string)
func (*RuntimeManager) FindWarmRuntime ¶
func (m *RuntimeManager) FindWarmRuntime(req *InvocationInput) *RuntimeInfo
FindWarmRuntime
func (*RuntimeManager) GetRuntime ¶
func (m *RuntimeManager) GetRuntime(runtimeID string) (ri *RuntimeInfo, err error)
func (*RuntimeManager) IncreaseUsedResource ¶
func (m *RuntimeManager) IncreaseUsedResource(rs *api.Resource) bool
ReleaseUsedResource
func (*RuntimeManager) NewRuntime ¶
func (m *RuntimeManager) NewRuntime(params *NewRuntimeParameters) *RuntimeInfo
func (*RuntimeManager) OccupyColdRuntime ¶
func (m *RuntimeManager) OccupyColdRuntime(req *InvocationInput) (ri *RuntimeInfo, recommend *api.ScaleUpRecommendation)
OccupyColdRuntime
func (*RuntimeManager) ReleaseMarkedResource ¶
func (m *RuntimeManager) ReleaseMarkedResource(rs *api.Resource) bool
ReleaseUsedResource
func (*RuntimeManager) ReleaseUsedResource ¶
func (m *RuntimeManager) ReleaseUsedResource(rs *api.Resource) bool
ReleaseUsedResource
func (*RuntimeManager) ResetRuntime ¶
func (m *RuntimeManager) ResetRuntime(runtime *RuntimeInfo) (recommend *api.ScaleDownRecommendation, err error)
func (*RuntimeManager) ResourceStatistics ¶
func (m *RuntimeManager) ResourceStatistics() (resource *api.ServiceResource)
func (*RuntimeManager) RuntimeList ¶
func (m *RuntimeManager) RuntimeList() []*RuntimeInfo
func (*RuntimeManager) RuntimeStatistics ¶
func (m *RuntimeManager) RuntimeStatistics() (cold, inUse, all int)
func (*RuntimeManager) String ¶
func (m *RuntimeManager) String() string
func (*RuntimeManager) SyncResource ¶
func (m *RuntimeManager) SyncResource(resource *api.FuncletResource) bool
func (*RuntimeManager) SyncRuntimeResource ¶
type RuntimeMatchError ¶
type RuntimeMatchError struct {
Reason string
}
RuntimeMatchError
func (RuntimeMatchError) Error ¶
func (e RuntimeMatchError) Error() string
type RuntimeNoNeedToReset ¶
type RuntimeNoNeedToReset struct {
RuntimeID string
}
RuntimeNoNeedToReset
func (RuntimeNoNeedToReset) Error ¶
func (e RuntimeNoNeedToReset) Error() string
type RuntimeNotExist ¶
type RuntimeNotExist struct {
RuntimeID string
}
RuntimeNotExist: runtime does not exist
func (RuntimeNotExist) Error ¶
func (e RuntimeNotExist) Error() string
type RuntimeReleaseError ¶
RuntimeReleaseError: release runtime failed
func (RuntimeReleaseError) Error ¶
func (e RuntimeReleaseError) Error() string
type RuntimeStateType ¶
type RuntimeStateType = string
const ( RuntimeStateCold RuntimeStateType = "cold" RuntimeStateWarmUp RuntimeStateType = "warmup" RuntimeStateWarm RuntimeStateType = "warm" RuntimeStateMerged RuntimeStateType = "merged" RuntimeStateStopping RuntimeStateType = "stopping" RuntimeStateStopped RuntimeStateType = "stopped" RuntimeStateClosed RuntimeStateType = "closed" RuntimeStateReclaiming RuntimeStateType = "reclaiming" )
type RuntimeStateUnmatched ¶
type RuntimeStateUnmatched struct {
RuntimeID string
CurrentState RuntimeStateType
ExpectedState []RuntimeStateType
}
func (RuntimeStateUnmatched) Error ¶
func (e RuntimeStateUnmatched) Error() string
type RuntimeSyncError ¶
RuntimeReleaseError: release runtime failed
func (RuntimeSyncError) Error ¶
func (e RuntimeSyncError) Error() string
type StatisticInfo ¶
type StatisticInfo struct {
UserID string `json:"userid"`
RequestID string `json:"reqid,omitempty"`
Function string `json:"function"`
Version string `json:"version"`
StartTime int64 `json:"startms"`
Duration float64 `json:"duration"`
MemoryUsed int64 `json:"memused"`
StatusCode int `json:"status"`
}
func (*StatisticInfo) Decode ¶
func (si *StatisticInfo) Decode(str string) error
func (*StatisticInfo) Encode ¶
func (si *StatisticInfo) Encode() string
type UserLogType ¶
type UserLogType string
const ( UserLogTypePlain UserLogType = "plain" UserLogTypeJson UserLogType = "json" )
func (UserLogType) Valid ¶
func (u UserLogType) Valid() bool
Click to show internal directories.
Click to hide internal directories.