本文整理匯總了Golang中github.com/eclipse/che/exec-agent/rpc.Transmitter.Send方法的典型用法代碼示例。如果您正苦於以下問題:Golang Transmitter.Send方法的具體用法?Golang Transmitter.Send怎麽用?Golang Transmitter.Send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eclipse/che/exec-agent/rpc.Transmitter
的用法示例。
在下文中一共展示了Transmitter.Send方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: subscribeReqHF
func subscribeReqHF(params interface{}, t *rpc.Transmitter) error {
subscribeParams := params.(SubscribeParams)
mask := maskFromTypes(subscribeParams.EventTypes)
if mask == 0 {
return rpc.NewArgsError(errors.New("Required at least 1 valid event type"))
}
subscriber := Subscriber{
Id: t.Channel.Id,
Mask: mask,
Channel: t.Channel.Events,
}
// Check whether subscriber should see previous logs or not
if subscribeParams.After == "" {
if err := AddSubscriber(subscribeParams.Pid, subscriber); err != nil {
return asRpcError(err)
}
} else {
after, err := time.Parse(DateTimeFormat, subscribeParams.After)
if err != nil {
return rpc.NewArgsError(errors.New("Bad format of 'after', " + err.Error()))
}
if err := RestoreSubscriber(subscribeParams.Pid, subscriber, after); err != nil {
return err
}
}
t.Send(&SubscribeResult{
Pid: subscribeParams.Pid,
EventTypes: subscribeParams.EventTypes,
Text: "Successfully subscribed",
})
return nil
}
示例2: getProcessReqHF
func getProcessReqHF(body interface{}, t *rpc.Transmitter) error {
params := body.(GetProcessParams)
p, err := Get(params.Pid)
if err != nil {
return asRpcError(err)
}
t.Send(p)
return nil
}
示例3: unsubscribeReqHF
func unsubscribeReqHF(params interface{}, t *rpc.Transmitter) error {
unsubscribeParams := params.(UnsubscribeParams)
if err := RemoveSubscriber(unsubscribeParams.Pid, t.Channel.Id); err != nil {
return asRpcError(err)
}
t.Send(&ProcessResult{
Pid: unsubscribeParams.Pid,
Text: "Successfully unsubscribed",
})
return nil
}
示例4: killProcessReqHF
func killProcessReqHF(params interface{}, t *rpc.Transmitter) error {
killParams := params.(KillParams)
if err := Kill(killParams.Pid); err != nil {
return asRpcError(err)
}
t.Send(&ProcessResult{
Pid: killParams.Pid,
Text: "Successfully killed",
})
return nil
}
示例5: updateSubscriberReqHF
func updateSubscriberReqHF(params interface{}, t *rpc.Transmitter) error {
updateParams := params.(UpdateSubscriberParams)
if updateParams.EventTypes == "" {
return rpc.NewArgsError(errors.New("'eventTypes' required for subscriber update"))
}
if err := UpdateSubscriber(updateParams.Pid, t.Channel.Id, maskFromTypes(updateParams.EventTypes)); err != nil {
return asRpcError(err)
}
t.Send(&SubscribeResult{
Pid: updateParams.Pid,
EventTypes: updateParams.EventTypes,
Text: "Subscriber successfully updated",
})
return nil
}
示例6: getProcessLogsReqHF
func getProcessLogsReqHF(params interface{}, t *rpc.Transmitter) error {
getLogsParams := params.(GetLogsParams)
if getLogsParams.Skip < 0 {
getLogsParams.Skip = 0
}
if getLogsParams.Limit < 0 {
getLogsParams.Limit = 0
}
from, err := parseTime(getLogsParams.From, time.Time{})
if err != nil {
return rpc.NewArgsError(errors.New("Bad format of 'from', " + err.Error()))
}
till, err := parseTime(getLogsParams.Till, time.Now())
if err != nil {
return rpc.NewArgsError(errors.New("Bad format of 'till', " + err.Error()))
}
logs, err := ReadLogs(getLogsParams.Pid, from, till)
if err != nil {
return asRpcError(err)
}
limit := DefaultLogsPerPageLimit
if getLogsParams.Limit != 0 {
if limit < 1 {
return rpc.NewArgsError(errors.New("Required 'limit' to be > 0"))
}
limit = getLogsParams.Limit
}
skip := 0
if getLogsParams.Skip != 0 {
if skip < 0 {
return rpc.NewArgsError(errors.New("Required 'skip' to be >= 0"))
}
skip = getLogsParams.Skip
}
logsLen := len(logs)
fromIdx := int(math.Max(float64(logsLen-limit-skip), 0))
toIdx := logsLen - int(math.Min(float64(skip), float64(logsLen)))
t.Send(logs[fromIdx:toIdx])
return nil
}
示例7: startProcessReqHF
func startProcessReqHF(params interface{}, t *rpc.Transmitter) error {
startParams := params.(StartParams)
command := Command{
Name: startParams.Name,
CommandLine: startParams.CommandLine,
Type: startParams.Type,
}
if err := checkCommand(&command); err != nil {
return rpc.NewArgsError(err)
}
_, err := NewBuilder().
Cmd(command).
FirstSubscriber(Subscriber{
Id: t.Channel.Id,
Mask: parseTypes(startParams.EventTypes),
Channel: t.Channel.Events,
}).
BeforeEventsHook(func(process MachineProcess) {
t.Send(process)
}).
Start()
return err
}
示例8: getProcessesReqHF
func getProcessesReqHF(body interface{}, t *rpc.Transmitter) error {
params := body.(GetProcessesParams)
t.Send(GetProcesses(params.All))
return nil
}