Skip to content

Commit

Permalink
Make the example command buildable on macOS
Browse files Browse the repository at this point in the history
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
  • Loading branch information
kzys committed May 22, 2021
1 parent 616d54c commit 2368990
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
23 changes: 23 additions & 0 deletions example/cmd/handshaker_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright The containerd 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 main

import ttrpc "github.com/containerd/ttrpc"

func defaultHandshaker() ttrpc.Handshaker {
return ttrpc.UnixSocketRequireSameUser()
}
25 changes: 25 additions & 0 deletions example/cmd/handshaker_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// +build !linux

/*
Copyright The containerd 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 main

import ttrpc "github.com/containerd/ttrpc"

func defaultHandshaker() ttrpc.Handshaker {
return nil
}
2 changes: 1 addition & 1 deletion example/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func dumpMetadata(ctx context.Context) {

func server() error {
s, err := ttrpc.NewServer(
ttrpc.WithServerHandshaker(ttrpc.UnixSocketRequireSameUser()),
ttrpc.WithServerHandshaker(defaultHandshaker()),
ttrpc.WithUnaryServerInterceptor(serverIntercept),
)
if err != nil {
Expand Down

0 comments on commit 2368990

Please sign in to comment.