go.ligato.io/vpp-agent/v3@v3.5.0/examples/tutorials/08_grpc/cmd/client/main.go (about) 1 // Copyright (c) 2019 Cisco and/or its affiliates. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at: 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package main 16 17 import ( 18 "go.ligato.io/cn-infra/v2/agent" 19 20 "go.ligato.io/vpp-agent/v3/examples/tutorials/08_grpc/plugins/grpc" 21 ) 22 23 func main() { 24 // Prepare the App instance 25 a := agent.NewAgent( 26 agent.AllPlugins(New()), 27 ) 28 29 // Start the App 30 if err := a.Run(); err != nil { 31 panic(err) 32 } 33 } 34 35 // App represents application with the GRPC plugin 36 type App struct { 37 GRPC *grpc.Client 38 } 39 40 // New starts new GRPC app 41 func New() *App { 42 return &App{ 43 GRPC: &grpc.DefaultPlugin, 44 } 45 } 46 47 // Init is empty, only to implement Plugin interface 48 func (App) Init() error { 49 return nil 50 } 51 52 // Close is empty 53 func (App) Close() error { 54 return nil 55 } 56 57 // String returns app plugin name 58 func (App) String() string { 59 return "App-grpc-client" 60 }