GithubHelp home page GithubHelp logo

edwarnicke / fdio-govpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fdio/govpp

0.0 1.0 0.0 7.14 MB

License: Apache License 2.0

C 1.22% Go 97.59% Makefile 0.80% Dockerfile 0.30% HTML 0.08%

fdio-govpp's Introduction

GoVPP

stable PkgGoDev

The GoVPP repository contains a Go client library for interacting with the VPP, generator of Go bindings for the VPP binary API and various other tooling for VPP.

Overview

Here is a brief overview for the repository structure.

  • govpp - the entry point for the GoVPP client
    • adapter - VPP binary & stats API interface
      • mock - Mock adapter used for testing
      • socketclient - Go implementation of VPP API client for unix socket
      • statsclient - Go implementation of VPP Stats client for shared memory
      • vppapiclient - CGo wrapper of vppapiclient library (DEPRECATED!)
    • api - GoVPP client API
    • binapigen - library for generating code from VPP API
    • cmd/
    • codec - handles encoding/decoding of generated messages into binary form
    • core - implementation of the GoVPP client
    • docs - documentation
    • examples - examples demonstrating GoVPP functionality
    • internal - packages used internally by GoVPP
    • proxy - contains client/server implementation for proxy
    • test - integration tests, benchmarks and performance tests

Quick Start

Below are some code examples showing GoVPP client interacting with VPP API.

Using raw messages directly

Here is a code for low-level way to access the VPP API using the generated messages directly for sending/receiving.

package main

import (
    "log"
    
	"go.fd.io/govpp"
	"go.fd.io/govpp/binapi/interfaces"
	"go.fd.io/govpp/binapi/vpe"
)

func main() {
	// Connect to VPP
	conn, _ := govpp.Connect("/run/vpp/api.sock")
	defer conn.Disconnect()

	// Open channel
	ch, _ := conn.NewAPIChannel()
	defer ch.Close()

	// Prepare messages
	req := &vpe.ShowVersion{}
	reply := &vpe.ShowVersionReply{}

	// Send the request
	err := ch.SendRequest(req).ReceiveReply(reply)
	if err != nil {
        log.Fatal("ERROR: ", err)
	}

    log.Print("Version: ", reply.Version)
}

For a complete example see simple-client.

Using RPC service client

Here is a sample code for an effortless way to access the VPP API using a generated RPC service client for calling.

package main

import (
    "context"
    "log"

	"go.fd.io/govpp"
	"go.fd.io/govpp/binapi/vpe"
)

func main() {
	// Connect to VPP API socket
	conn, _ := govpp.Connect("/run/vpp/api.sock")
	defer conn.Disconnect()

	// Init vpe service client
    client := vpe.NewServiceClient(conn)

	reply, err := client.ShowVersion(context.Background(), &vpe.ShowVersion{})
	if err != nil {
		log.Fatal("ERROR: ", err)
	}

	log.Print("Version: ", reply.Version)
}

For a complete example see rpc-service.

More code examples

More examples can be found in examples directory.

  • api-trace - trace sent/received messages
  • binapi-types - using common types from generated code
  • multi-vpp - connect to multiple VPP instances
  • perf-bench - very basic performance test for measuring throughput
  • rpc-service - effortless way to call VPP API via RPC client
  • simple-client - send and receive VPP API messages using GoVPP API directly
  • stats-client - client for retrieving VPP stats data
  • stream-client - using new stream API to call VPP API

Documentation

Further documentation can be found in docs directory.

  • Adapters - detailed info about transport adapters and their implementations
  • Binapi Generator - user guide for generating VPP binary API

fdio-govpp's People

Contributors

ondrej-fabry avatar vladolavor avatar rastislavs avatar sknat avatar edwarnicke avatar lukasmacko avatar deathbeam avatar mhalaj1 avatar matus-mrekaj avatar nplanel avatar serejkus avatar vvalderrv avatar hurd54 avatar aloysaugustin avatar lukedirtwalker avatar toravir avatar bayrinat avatar sbezverk avatar brecode avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.