GithubHelp home page GithubHelp logo

agx's Introduction

agx

An AgentX library for Go

Rationale

There are already a few other AgentX libraries for Go out there. However, none of the ones I found seem to support setting variables, and most seem to be built with a relatively static devices in mind. agx is purposely designed to support managing highly dynamic devices. Both set and get operations are exposed through functional interfaces that allow your code to be executed when GET or SET operations come through the pipes.

Disclaimer

I am still pushing toward an initial release and the library is not yet fully functional.

Basic Usage

The example below sets up an agent to manage vlans using the Q-BRIDGE standard.

package main

import "github.com/rcgoodfellow/agx"

func main() {
	id, descr := "qbridge-agent", "agent for controlling valns"
	qbridge := "1.3.6.1.2.1.17"
	
	c, err := agx.Connect(&id, &descr)
	defer c.Disconnect()
	
	c.Register(qbridge)
	defer c.Unregister(qbridge)

	c.OnGet(qbridge, func(oid agx.Subtree) agx.VarBind {

		var v agx.VarBind
		v.Type = agx.OctetStringT
		v.Name = oid
		v.Data = *agx.NewOctetString(string([]byte{0xcc, 0x33}))
		return v

	})
	c.OnTestSet(qvs, func(vb agx.VarBind, sessionId int) agx.TestSetResult {

		log.Printf("[test-set] oid::%s session=%d", vb.Name.String(), sessionId)
		
		//do something to test whether the set operation is valid for your device here
		
		return agx.TestSetNoError
	}
	c.OnCommitSet(func(sessionId int) agx.CommitSetResult {

		log.Printf("[commit-set] session=%d", sessionId)
		
		//do something to implement the set here

		return agx.CommitSetNoError

	})

	//wait for connection to close
	<-c.Closed
}

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.