From 9637fb866478d7b91acc5f29e37e1171c6697e53 Mon Sep 17 00:00:00 2001 From: Yuxuan Li Date: Tue, 29 May 2018 11:22:34 -0700 Subject: [PATCH] add init --- channelz/service/util_386.go | 33 +++++++++++++++++++++++++++++++++ channelz/service/util_amd64.go | 32 ++++++++++++++++++++++++++++++++ channelz/types_nonlinux.go | 6 ++++++ 3 files changed, 71 insertions(+) create mode 100644 channelz/service/util_386.go create mode 100644 channelz/service/util_amd64.go diff --git a/channelz/service/util_386.go b/channelz/service/util_386.go new file mode 100644 index 000000000000..d9c981271361 --- /dev/null +++ b/channelz/service/util_386.go @@ -0,0 +1,33 @@ +// +build 386,linux + +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package service + +import ( + "golang.org/x/sys/unix" + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +func protoToTime(protoTime *channelzpb.SocketOptionTimeout) *unix.Timeval { + timeout := &unix.Timeval{} + sec, usec := convertToDuration(protoTime.GetDuration()) + timeout.Sec, timeout.Usec = int32(sec), int32(usec) + return timeout +} diff --git a/channelz/service/util_amd64.go b/channelz/service/util_amd64.go new file mode 100644 index 000000000000..0ff06d128330 --- /dev/null +++ b/channelz/service/util_amd64.go @@ -0,0 +1,32 @@ +// +build amd64,linux + +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package service + +import ( + "golang.org/x/sys/unix" + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +func protoToTime(protoTime *channelzpb.SocketOptionTimeout) *unix.Timeval { + timeout := &unix.Timeval{} + timeout.Sec, timeout.Usec = convertToDuration(protoTime.GetDuration()) + return timeout +} diff --git a/channelz/types_nonlinux.go b/channelz/types_nonlinux.go index d59d5e02c674..0791cce59afb 100644 --- a/channelz/types_nonlinux.go +++ b/channelz/types_nonlinux.go @@ -20,6 +20,12 @@ package channelz +import "google.golang.org/grpc/grpclog" + +func init() { + grpclog.Infof("Channelz: socket options are not supported on non-linux os.") +} + // SocketOptionData defines the struct to hold socket option data, and related // getter function to obtain info from fd. // Windows OS doesn't support Socket Option