Skip to content

Commit

Permalink
add init
Browse files Browse the repository at this point in the history
  • Loading branch information
lyuxuan committed May 29, 2018
1 parent 02e23b1 commit 4265c7d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
33 changes: 33 additions & 0 deletions channelz/service/util_386.go
Original file line number Diff line number Diff line change
@@ -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
}
32 changes: 32 additions & 0 deletions channelz/service/util_amd64.go
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 6 additions & 0 deletions channelz/types_nonlinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4265c7d

Please sign in to comment.