go.ligato.io/vpp-agent/v3@v3.5.0/plugins/govppmux/adapter_puregoclient.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 //go:build !mockvpp && !vppapiclient 16 17 package govppmux 18 19 import ( 20 "fmt" 21 "os" 22 23 "go.fd.io/govpp/adapter" 24 "go.fd.io/govpp/adapter/socketclient" 25 "go.fd.io/govpp/adapter/statsclient" 26 ) 27 28 const noShmWarning = `Using shared memory for VPP binary API is not currently supported in pure Go client! 29 30 To use socket client for VPP binary API (recommended): 31 - unset GOVPPMUX_NOSOCK environment variable 32 - remove these settings from govpp.conf config: shm-prefix, connect-via-shm 33 34 If you still want to use shared memory for VPP binary API: 35 - compile your agent with this build tag: vppapiclient 36 - vppapiclient requires CGo and needs VPP to be installed 37 ` 38 39 // NewVppAdapter returns VPP binary API adapter, implemented as pure Go client. 40 func NewVppAdapter(addr string, useShm bool) adapter.VppAPI { 41 if useShm { 42 fmt.Fprint(os.Stderr, noShmWarning) 43 panic("No implementation for shared memory in pure Go client!") 44 } 45 // addr is used as socket path 46 return socketclient.NewVppClient(addr) 47 } 48 49 // NewStatsAdapter returns VPP stats API adapter, implemented as pure Go client. 50 func NewStatsAdapter(socketName string) adapter.StatsAPI { 51 return statsclient.NewStatsClient(socketName) 52 }