|
| 1 | +/* |
| 2 | + * |
| 3 | + * Copyright 2015 gRPC authors. |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + * |
| 17 | + */ |
| 18 | + |
| 19 | +// Package main implements a simple gRPC client that demonstrates how to use gRPC-Go libraries |
| 20 | +// to perform unary, client streaming, server streaming and full duplex RPCs. |
| 21 | +// |
| 22 | +// It interacts with the route guide service whose definition can be found in routeguide/route_guide.proto. |
| 23 | +package main |
| 24 | + |
| 25 | +import ( |
| 26 | + "io" |
| 27 | + "log" |
| 28 | + |
| 29 | + pb "arduino.cc/builder/grpc/proto" |
| 30 | + "golang.org/x/net/context" |
| 31 | + "google.golang.org/grpc" |
| 32 | +) |
| 33 | + |
| 34 | +// printFeature gets the feature for the given point. |
| 35 | +func autocomplete(client pb.BuilderClient, in *pb.BuildParams) { |
| 36 | + resp, err := client.Autocomplete(context.Background(), in) |
| 37 | + if err != nil { |
| 38 | + log.Fatalf("%v.GetFeatures(_) = _, %v: ", client, err) |
| 39 | + } |
| 40 | + log.Println(resp) |
| 41 | +} |
| 42 | + |
| 43 | +// printFeatures lists all the features within the given bounding Rectangle. |
| 44 | +func build(client pb.BuilderClient, in *pb.BuildParams) { |
| 45 | + stream, err := client.Build(context.Background(), in) |
| 46 | + if err != nil { |
| 47 | + log.Fatalf("%v.ListFeatures(_) = _, %v", client, err) |
| 48 | + } |
| 49 | + for { |
| 50 | + line, err := stream.Recv() |
| 51 | + if err == io.EOF { |
| 52 | + break |
| 53 | + } |
| 54 | + if err != nil { |
| 55 | + log.Fatalf("%v.ListFeatures(_) = _, %v", client, err) |
| 56 | + } |
| 57 | + log.Println(line) |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +func main() { |
| 62 | + conn, err := grpc.Dial("localhost:12345", grpc.WithInsecure()) |
| 63 | + if err != nil { |
| 64 | + log.Fatalf("fail to dial: %v", err) |
| 65 | + } |
| 66 | + defer conn.Close() |
| 67 | + |
| 68 | + client := pb.NewBuilderClient(conn) |
| 69 | + |
| 70 | + exampleParames := pb.BuildParams{ |
| 71 | + BuiltInLibrariesFolders: "/ssd/Arduino-master/build/linux/work/libraries", |
| 72 | + CustomBuildProperties: "build.warn_data_percentage=75", |
| 73 | + FQBN: "arduino:avr:mega:cpu=atmega2560", |
| 74 | + HardwareFolders: "/ssd/Arduino-master/build/linux/work/hardware,/home/martino/.arduino15/packages,/home/martino/eslov-sk/hardware", |
| 75 | + OtherLibrariesFolders: "/home/martino/eslov-sk/libraries", |
| 76 | + ArduinoAPIVersion: "10805", |
| 77 | + SketchLocation: "/home/martino/eslov-sk/libraries/WiFi101/examples/ScanNetworks/ScanNetworks.ino", |
| 78 | + ToolsFolders: "/ssd/Arduino-master/build/linux/work/tools-builder,/ssd/Arduino-master/build/linux/work/hardware/tools/avr,/home/martino/.arduino15/packages", |
| 79 | + Verbose: true, |
| 80 | + WarningsLevel: "all", |
| 81 | + BuildCachePath: "/tmp/arduino_cache_761418/", |
| 82 | + CodeCompleteAt: "/home/martino/eslov-sk/libraries/WiFi101/examples/ScanNetworks/ScanNetworks.ino:1:1", |
| 83 | + } |
| 84 | + |
| 85 | + build(client, &exampleParames) |
| 86 | + //autocomplete(client, &exampleParames) |
| 87 | +} |
0 commit comments