aboutsummaryrefslogtreecommitdiffstats
path: root/govpp.go
diff options
context:
space:
mode:
authorRastislav Szabo <raszabo@cisco.com>2017-05-04 11:09:03 +0200
committerRastislav Szabo <raszabo@cisco.com>2017-05-04 11:12:35 +0200
commita101d966133a70b8a76526be25070436d14fcf9f (patch)
tree75e2dbf20de615e58252b780b2ba5baae8fdcf82 /govpp.go
parenta968ead74525125dff9ae90b1c9a9102e4327900 (diff)
initial commit
Signed-off-by: Rastislav Szabo <raszabo@cisco.com>
Diffstat (limited to 'govpp.go')
-rw-r--r--govpp.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/govpp.go b/govpp.go
new file mode 100644
index 0000000..f0ced41
--- /dev/null
+++ b/govpp.go
@@ -0,0 +1,37 @@
+// Copyright (c) 2017 Cisco and/or its affiliates.
+//
+// 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 govpp
+
+import (
+ "gerrit.fd.io/r/govpp/adapter"
+ "gerrit.fd.io/r/govpp/adapter/vppapiclient"
+ "gerrit.fd.io/r/govpp/core"
+)
+
+var vppAdapter adapter.VppAdapter // VPP Adapter that will be used in the subsequent Connect calls
+
+// Connect connects the govpp core to VPP either using the default VPP Adapter, or using the adapter previously
+// set by SetAdapter (useful mostly just for unit/integration tests with mocked VPP adapter).
+func Connect() (*core.Connection, error) {
+ if vppAdapter == nil {
+ vppAdapter = vppapiclient.NewVppAdapter()
+ }
+ return core.Connect(vppAdapter)
+}
+
+// SetAdapter sets the adapter that will be used for connections to VPP in the subsequent `Connect` calls.
+func SetAdapter(ad adapter.VppAdapter) {
+ vppAdapter = ad
+}