From a101d966133a70b8a76526be25070436d14fcf9f Mon Sep 17 00:00:00 2001 From: Rastislav Szabo Date: Thu, 4 May 2017 11:09:03 +0200 Subject: initial commit Signed-off-by: Rastislav Szabo --- govpp.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 govpp.go (limited to 'govpp.go') 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 +} -- cgit 1.2.3-korg