cubefs

Форк
0
76 строк · 2.0 Кб
1
// +build !linux appengine
2

3
/*
4
 *
5
 * Copyright 2018 gRPC authors.
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 *
19
 */
20

21
// Package syscall provides functionalities that grpc uses to get low-level
22
// operating system stats/info.
23
package syscall
24

25
import (
26
	"net"
27
	"sync"
28
	"time"
29

30
	"google.golang.org/grpc/grpclog"
31
)
32

33
var once sync.Once
34
var logger = grpclog.Component("core")
35

36
func log() {
37
	once.Do(func() {
38
		logger.Info("CPU time info is unavailable on non-linux or appengine environment.")
39
	})
40
}
41

42
// GetCPUTime returns the how much CPU time has passed since the start of this process.
43
// It always returns 0 under non-linux or appengine environment.
44
func GetCPUTime() int64 {
45
	log()
46
	return 0
47
}
48

49
// Rusage is an empty struct under non-linux or appengine environment.
50
type Rusage struct{}
51

52
// GetRusage is a no-op function under non-linux or appengine environment.
53
func GetRusage() *Rusage {
54
	log()
55
	return nil
56
}
57

58
// CPUTimeDiff returns the differences of user CPU time and system CPU time used
59
// between two Rusage structs. It a no-op function for non-linux or appengine environment.
60
func CPUTimeDiff(first *Rusage, latest *Rusage) (float64, float64) {
61
	log()
62
	return 0, 0
63
}
64

65
// SetTCPUserTimeout is a no-op function under non-linux or appengine environments
66
func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error {
67
	log()
68
	return nil
69
}
70

71
// GetTCPUserTimeout is a no-op function under non-linux or appengine environments
72
// a negative return value indicates the operation is not supported
73
func GetTCPUserTimeout(conn net.Conn) (int, error) {
74
	log()
75
	return -1, nil
76
}
77

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.