1 Star 0 Fork 0

xingyp / cn-infra

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.go 1.65 KB
一键复制 编辑 原始数据 按行查看 历史
Ondrej Fabry 提交于 2019-02-25 10:19 . Add tutorials
// Copyright (c) 2019 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 main
import (
"log"
"github.com/ligato/cn-infra/agent"
)
func main() {
// Create an instance of our plugin.
p := new(HelloWorld)
// Create new agent with our plugin instance.
a := agent.NewAgent(agent.Plugins(p))
// Run starts the agent with plugins, wait until shutdown
// and then stops the agent and its plugins.
if err := a.Run(); err != nil {
log.Fatalln(err)
}
}
// HelloWorld represents our plugin.
type HelloWorld struct{}
// String is used to identify the plugin by giving it name.
func (p *HelloWorld) String() string {
return "HelloWorld"
}
// Init is executed on agent initialization.
func (p *HelloWorld) Init() error {
log.Println("Hello World!")
return nil
}
// AfterInit is executed after initialization of all plugins. It's optional
// and used for executing operations that require plugins to be initalized.
func (p *HelloWorld) AfterInit() error {
log.Println("All systems go!")
return nil
}
// Close is executed on agent shutdown.
func (p *HelloWorld) Close() error {
log.Println("Goodbye World!")
return nil
}
1
https://gitee.com/xingyp/cn-infra.git
git@gitee.com:xingyp/cn-infra.git
xingyp
cn-infra
cn-infra
v2.2.0

搜索帮助