Recognize stat_dir_type_empty
[govpp.git] / govpp.go
1 // Copyright (c) 2017 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 govpp
16
17 import (
18         "time"
19
20         "git.fd.io/govpp.git/adapter"
21         "git.fd.io/govpp.git/adapter/socketclient"
22         "git.fd.io/govpp.git/core"
23         "git.fd.io/govpp.git/internal/version"
24 )
25
26 // Connect connects to the VPP API using a new adapter instance created with NewVppAPIAdapter.
27 //
28 // This call blocks until VPP is connected, or an error occurs.
29 // Only one connection attempt will be performed.
30 func Connect(target string) (*core.Connection, error) {
31         return core.Connect(NewVppAdapter(target))
32 }
33
34 // AsyncConnect asynchronously connects to the VPP API using a new adapter instance
35 // created with NewVppAPIAdapter.
36 //
37 // This call does not block until connection is established, it returns immediately.
38 // The caller is supposed to watch the returned ConnectionState channel for connection events.
39 // In case of disconnect, the library will asynchronously try to reconnect.
40 func AsyncConnect(target string, attempts int, interval time.Duration) (*core.Connection, chan core.ConnectionEvent, error) {
41         return core.AsyncConnect(NewVppAdapter(target), attempts, interval)
42 }
43
44 // NewVppAdapter returns new instance of VPP adapter for connecting to VPP API.
45 var NewVppAdapter = func(target string) adapter.VppAPI {
46         return socketclient.NewVppClient(target)
47 }
48
49 // Version returns version of GoVPP.
50 func Version() string {
51         return version.String()
52 }