github.com/cloudwego/kitex@v0.9.0/pkg/remote/trans/nphttp2/grpc/syscall/syscall_nonlinux.go (about) 1 //go:build !linux 2 // +build !linux 3 4 /* 5 * 6 * Copyright 2018 gRPC authors. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 * 20 * This file may have been modified by CloudWeGo authors. All CloudWeGo 21 * Modifications are Copyright 2021 CloudWeGo Authors. 22 */ 23 24 // Package syscall provides functionalities that grpc uses to get low-level 25 // operating system stats/info. 26 package syscall 27 28 import ( 29 "net" 30 "sync" 31 "time" 32 33 "github.com/cloudwego/kitex/pkg/klog" 34 ) 35 36 var once sync.Once 37 38 func log() { 39 once.Do(func() { 40 klog.Info("CPU time info is unavailable on non-linux environments.") 41 }) 42 } 43 44 // GetCPUTime returns the how much CPU time has passed since the start of this 45 // process. It always returns 0 under non-linux environments. 46 func GetCPUTime() int64 { 47 log() 48 return 0 49 } 50 51 // Rusage is an empty struct under non-linux environments. 52 type Rusage struct{} 53 54 // GetRusage is a no-op function under non-linux environments. 55 func GetRusage() *Rusage { 56 log() 57 return nil 58 } 59 60 // CPUTimeDiff returns the differences of user CPU time and system CPU time used 61 // between two Rusage structs. It a no-op function for non-linux environments. 62 func CPUTimeDiff(first, latest *Rusage) (float64, float64) { 63 log() 64 return 0, 0 65 } 66 67 // SetTCPUserTimeout is a no-op function under non-linux environments. 68 func SetTCPUserTimeout(conn net.Conn, timeout time.Duration) error { 69 log() 70 return nil 71 } 72 73 // GetTCPUserTimeout is a no-op function under non-linux environments. 74 // A negative return value indicates the operation is not supported 75 func GetTCPUserTimeout(conn net.Conn) (int, error) { 76 log() 77 return -1, nil 78 }