當前位置: 首頁>>代碼示例>>Golang>>正文


Golang rpc.Transmitter類代碼示例

本文整理匯總了Golang中github.com/eclipse/che/exec-agent/rpc.Transmitter的典型用法代碼示例。如果您正苦於以下問題:Golang Transmitter類的具體用法?Golang Transmitter怎麽用?Golang Transmitter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Transmitter類的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
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:34,代碼來源:ws_service.go

示例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
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:9,代碼來源:ws_service.go

示例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
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:11,代碼來源:ws_service.go

示例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
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:11,代碼來源:ws_service.go

示例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
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:15,代碼來源:ws_service.go

示例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
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:48,代碼來源:ws_service.go

示例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
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:24,代碼來源:ws_service.go

示例8: getProcessesReqHF

func getProcessesReqHF(body interface{}, t *rpc.Transmitter) error {
	params := body.(GetProcessesParams)
	t.Send(GetProcesses(params.All))
	return nil
}
開發者ID:sleshchenko,項目名稱:che,代碼行數:5,代碼來源:ws_service.go


注:本文中的github.com/eclipse/che/exec-agent/rpc.Transmitter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。