Browse Source

Remove Go Echo sample.

Tim Burks 8 years ago
parent
commit
2f6b957b81

+ 0 - 15
Examples/Echo/Go/CLEANUP

@@ -1,15 +0,0 @@
-#/bin/sh
-
-echo "Stopping the server (if running)"
-killall server
-
-echo "Removing compiled files"
-rm -rf client server go/bin go/pkg
-
-echo "Removing downloaded dependencies" 
-rm -rf go/src/github.com/ go/src/golang.org/ go/src/google.golang.org/
-
-echo "Removing generated files"
-rm -rf go/src/echo/echo.pb.go
-
-

+ 0 - 25
Examples/Echo/Go/INSTALL

@@ -1,25 +0,0 @@
-#!/bin/sh
-#
-# Prepare a new instance to run a Go gRPC sample app.
-#
-sudo apt-get update
-sudo apt-get install -y unzip  # we use unzip to unpack the protoc build
-sudo apt-get install -y psmisc # this provides killall, which is used by the SETUP script
-
-# Create a directory to contain tools that we need.
-mkdir $HOME/tools 
-
-# Download Go and install it in tools/go.
-wget https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
-tar -C $HOME/tools -xzf go1.6.linux-amd64.tar.gz
-
-# Download protoc and install it in tools/protobuf.
-wget https://github.com/google/protobuf/releases/download/v3.0.0-beta-2/protoc-3.0.0-beta-2-linux-x86_64.zip
-unzip protoc-3.0.0-beta-2-linux-x86_64.zip -d $HOME/tools/protobuf
-
-# Set the PATH and GOROOT.
-cat <<EOF >$HOME/.bash_profile
-export PATH=\$HOME/tools/go/bin:\$HOME/tools/protobuf:\$PATH
-export GOROOT=\$HOME/tools/go
-EOF
-

+ 0 - 50
Examples/Echo/Go/SETUP

@@ -1,50 +0,0 @@
-#!/bin/sh
-
-echo "0. Ensure that protoc is installed."
-
-if which protoc; then 
-  echo "OK"
-else 
-  echo "Please install protoc and be sure that it is in your search path."
-  exit
-fi
-
-echo "1. Set gopath and search path"
-
-export GOPATH=`pwd`/go
-export PATH=$GOPATH/bin:$PATH
-
-echo "2. Get the Go plugin for protoc"
-
-go get -a github.com/golang/protobuf/protoc-gen-go
-
-echo "3. Run protoc to generate the service API code"
-
-mkdir -p go/src/echo
-protoc ../echo.proto --proto_path=.. --go_out=plugins=grpc:go/src/echo
-
-echo "4. Get the server and client dependencies"
-
-go get server
-go get client
-
-echo "5. Build the server and client"
-
-go build server
-go build client
-
-echo "6. Stop any previously-running instances of the server"
-
-killall server
-
-echo "7. Start the server"
-
-./server &
-
-echo "8. Run the client"
-
-sleep 1 # give the server some time to start
-./client -m "Remember the milk."
-
-./client -m "Testing" -n 3 -update
-

+ 0 - 158
Examples/Echo/Go/go/src/client/client.go

@@ -1,158 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// 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 (
-	"flag"
-	"fmt"
-	"log"
-
-	"crypto/tls"
-	"io"
-
-	pb "echo"
-	"golang.org/x/net/context"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/credentials"
-)
-
-const (
-	defaultMessage = "hello"
-)
-
-func main() {
-	var get = flag.Bool("get", false, "call the Get method")
-	var update = flag.Bool("update", false, "call the Update method")
-	var collect = flag.Bool("collect", false, "call the Collect method")
-	var expand = flag.Bool("expand", false, "call the Expand method")
-	var count = flag.Int("n", 10, "number of message to send (update and collect only)")
-	var message = flag.String("m", defaultMessage, "the message to send")
-	var address = flag.String("a", "", "address of the echo server to use")
-	var useTLS = flag.Bool("tls", false, "Use tls for connections.")
-
-	flag.Parse()
-
-	// Set up a connection to the server.
-	var conn *grpc.ClientConn
-	var err error
-	if !*useTLS {
-		if *address == "" {
-			*address = "localhost:8080"
-		}
-		conn, err = grpc.Dial(*address, grpc.WithInsecure())
-	} else {
-		if *address == "" {
-			*address = "localhost:443"
-		}
-		conn, err = grpc.Dial(*address,
-			grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{
-				// remove the following line if the server certificate is signed by a certificate authority
-				InsecureSkipVerify: true,
-			})))
-	}
-
-	if err != nil {
-		log.Fatalf("did not connect: %v", err)
-	}
-
-	defer conn.Close()
-	c := pb.NewEchoClient(conn)
-	if *get {
-		call_get(c, *message)
-	}
-	if *update {
-		call_update(c, *message, *count)
-	}
-	if *collect {
-		call_collect(c, *message, *count)
-	}
-	if *expand {
-		call_expand(c, *message)
-	}
-}
-
-func call_get(c pb.EchoClient, message string) {
-	// Contact the server and print out its response.
-	response, err := c.Get(context.Background(), &pb.EchoRequest{Text: message})
-	if err != nil {
-		log.Fatalf("could not receive echo: %v", err)
-	}
-	log.Printf("Received: %s", response.Text)
-}
-
-func call_update(c pb.EchoClient, message string, count int) {
-	stream, err := c.Update(context.Background())
-	if err != nil {
-		panic(err)
-	}
-	waitc := make(chan struct{})
-	go func() {
-		for {
-			in, err := stream.Recv()
-			if err == io.EOF {
-				// read done.
-				close(waitc)
-				return
-			}
-			if err != nil {
-				log.Fatalf("Failed to receive an echo : %v", err)
-			}
-			log.Printf("Received: %s", in.Text)
-		}
-	}()
-	for i := 1; i <= count; i++ {
-		var note pb.EchoRequest
-		note.Text = fmt.Sprintf("%s %d", message, i)
-		if err := stream.Send(&note); err != nil {
-			log.Fatalf("Failed to send a message: %v", err)
-		}
-	}
-	stream.CloseSend()
-	<-waitc
-}
-
-func call_collect(c pb.EchoClient, message string, count int) {
-	stream, err := c.Collect(context.Background())
-	if err != nil {
-		panic(err)
-	}
-	for i := 1; i <= count; i++ {
-		var note pb.EchoRequest
-		note.Text = fmt.Sprintf("%s %d", message, i)
-		if err := stream.Send(&note); err != nil {
-			log.Fatalf("Failed to send a message: %v", err)
-		}
-	}
-	response, err := stream.CloseAndRecv()
-	log.Printf("Received: %s", response.Text)
-}
-
-func call_expand(c pb.EchoClient, message string) {
-	stream, err := c.Expand(context.Background(), &pb.EchoRequest{Text: message})
-	if err != nil {
-		panic(err)
-	}
-	for {
-		in, err := stream.Recv()
-		if err == io.EOF {
-			// read done.
-			return
-		}
-		if err != nil {
-			log.Fatalf("Failed to receive an echo : %v", err)
-		}
-		log.Printf("Received: %s", in.Text)
-	}
-}

+ 0 - 129
Examples/Echo/Go/go/src/server/server.go

@@ -1,129 +0,0 @@
-// Copyright 2016 Google Inc. All Rights Reserved.
-//
-// 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 (
-	"flag"
-	"fmt"
-	"io"
-	"log"
-	"net"
-	"strings"
-	"time"
-
-	pb "echo"
-	"golang.org/x/net/context"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/credentials"
-)
-
-type EchoServer struct{}
-
-var echoServer EchoServer
-
-// requests are immediately returned, no inbound or outbound streaming
-func (s *EchoServer) Get(ctx context.Context, request *pb.EchoRequest) (*pb.EchoResponse, error) {
-	fmt.Printf("Get received: %s\n", request.Text)
-	response := &pb.EchoResponse{}
-	response.Text = "Go echo get: " + request.Text
-	return response, nil
-}
-
-// requests stream in and are immediately streamed out
-func (s *EchoServer) Update(stream pb.Echo_UpdateServer) error {
-	count := 0
-	for {
-		request, err := stream.Recv()
-		if err == io.EOF {
-			return nil
-		}
-		if err != nil {
-			return err
-		}
-		fmt.Printf("Update received: %s\n", request.Text)
-		response := &pb.EchoResponse{}
-		response.Text = fmt.Sprintf("Go echo update (%d): %s", count, request.Text)
-		count++
-		if err := stream.Send(response); err != nil {
-			return err
-		}
-	}
-	return nil
-}
-
-// requests stream in, are appended together, and are returned in a single response when the input is closed
-func (s *EchoServer) Collect(stream pb.Echo_CollectServer) error {
-	parts := []string{}
-	for {
-		request, err := stream.Recv()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			return err
-		}
-		fmt.Printf("Collect received: %s\n", request.Text)
-		parts = append(parts, request.Text)
-	}
-	response := &pb.EchoResponse{}
-	response.Text = fmt.Sprintf("Go echo collect: %s", strings.Join(parts, " "))
-	if err := stream.SendAndClose(response); err != nil {
-		return err
-	}
-	return nil
-}
-
-// a single request is accepted and split into parts which are individually returned with a time delay
-func (s *EchoServer) Expand(request *pb.EchoRequest, stream pb.Echo_ExpandServer) error {
-	fmt.Printf("Expand received: %s\n", request.Text)
-	parts := strings.Split(request.Text, " ")
-	for i, part := range parts {
-		response := &pb.EchoResponse{}
-		response.Text = fmt.Sprintf("Go echo expand (%d): %s", i, part)
-		if err := stream.Send(response); err != nil {
-			return err
-		}
-		time.Sleep(1 * time.Second)
-	}
-	return nil
-}
-
-func main() {
-	var useTLS = flag.Bool("tls", false, "Use tls for connections.")
-
-	flag.Parse()
-
-	var err error
-	var lis net.Listener
-	var grpcServer *grpc.Server
-	if !*useTLS {
-		lis, err = net.Listen("tcp", ":8080")
-		if err != nil {
-			log.Fatalf("failed to listen: %v", err)
-		}
-		grpcServer = grpc.NewServer()
-	} else {
-		certFile := "ssl.crt"
-		keyFile := "ssl.key"
-		creds, err := credentials.NewServerTLSFromFile(certFile, keyFile)
-		lis, err = net.Listen("tcp", ":443")
-		if err != nil {
-			log.Fatalf("failed to listen: %v", err)
-		}
-		grpcServer = grpc.NewServer(grpc.Creds(creds))
-	}
-	pb.RegisterEchoServer(grpcServer, &echoServer)
-	grpcServer.Serve(lis)
-}

+ 0 - 17
Examples/Echo/Go/ssl.crt

@@ -1,17 +0,0 @@
------BEGIN CERTIFICATE-----
-MIICqDCCAZACCQC7L1EYvLe1FDANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtl
-eGFtcGxlLmNvbTAeFw0xNjAzMzEyMTA3NDZaFw0xNzAzMzEyMTA3NDZaMBYxFDAS
-BgNVBA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+SuubVAzTzXD2fi1Ls05T+tnkxtQhTJRb2vB
-IzkbgwKBgCuymXXQ41EzdJQoTWDe8CFLrP5ynKeaKzMN32ppUMbgb+DF4L9UpDm1
-CgckZ3THQEuh7yReY/2bU+XHK/GCdheNes+CXxu4dgSaVL/LONO08RuneDK1kQ5o
-e1oy4f+51rbwNGoUQ73U+cm/LSFJOir5EuNenpVZeMeQMktkg806
------END RSA PRIVATE KEY-----

+ 1 - 10
Examples/Echo/README.md

@@ -3,17 +3,8 @@
 This directory contains a simple echo server and client
 that demonstrates all four gRPC API styles (Unary, Server 
 Streaming, Client Streaming, and Bidirectional Streaming).
-It includes Swift and Go implementations to verify 
-interoperability.
 
 The [Xcode](Xcode) directory contains a Mac app and 
 [PackageManager](PackageManager) contains a command-line tool
 that can be built with the Swift Package Manager. Both contain
-a Swift client and server, and both are hard-coded to use port
-8081 for insecure connections and port 8443 for secure connections.
-
-The [Go](Go) directory contains a Go client and server. The Go server
-listens on port 8080 and the Go client connects to this by
-default but can be pointed at other servers using the "-a" 
-command-line option.
-
+a Swift client and server.