Exemplo n.º 1
0
func main() {
	p := pie.NewProvider()
	if err := p.RegisterName("Mapnik", api{}); err != nil {
		log.Fatalf("failed to register Plugin: %s", err)
	}
	p.Serve()
}
Exemplo n.º 2
0
// This function should be called from the plugin program that wants to provide
// functionality for the master program.
//
// This example shows the plugin starting a JSON-RPC server to be accessed by
// the master program. Server.ServeCodec() will block forever, so it is common
// to simply put this at the end of the plugin's main function.
func ExampleProvider_ServeCodec() {
	p := pie.NewProvider()
	if err := p.RegisterName("Foo", API{}); err != nil {
		log.Fatalf("can't register api: %s", err)
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
}
Exemplo n.º 3
0
// StartPlugin starts serving RPC requests and brokers data between RPC caller
// and the computation
func StartPlugin(impl ComputationImplementation) {
	provider := pie.NewProvider()
	computationPlugin := &ComputationPlugin{impl, sync.RWMutex{}}
	if err := provider.RegisterName("Computation", computationPlugin); err != nil {
		log.Fatalf("failed to register computation Plugin: %s", err)
	}
	provider.ServeCodec(jsonrpc.NewServerCodec)
}
Exemplo n.º 4
0
func RegisterVerifyResultFormatterPlugin(formatter VerifyResultFormatter) error {
	p := pie.NewProvider()
	if err := p.RegisterName("VerifyResultFormatter", &VerifyResultFormatterWrapper{formatter}); err != nil {
		return err
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
	return nil
}
Exemplo n.º 5
0
// Called once when the Plugin or CallPlugin function is used in Algernon
func main() {
	log.SetPrefix("[plugin log] ")
	p := pie.NewProvider()
	if err := p.RegisterName(namespace, LuaPlugin{}); err != nil {
		log.Fatalf("Failed to register plugin: %s", err)
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
}
Exemplo n.º 6
0
func RegisterDriverPlugin(driver Driver) error {
	p := pie.NewProvider()
	if err := p.RegisterName("Driver", &DriverWrapper{driver}); err != nil {
		return err
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
	return nil
}
Exemplo n.º 7
0
func main() {
	log.SetPrefix("[plugin log] ")

	p := pie.NewProvider()
	if err := p.RegisterName("HelloRPC", api{}); err != nil {
		log.Fatalf("failed to register Plugin: %s", err)
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
}
Exemplo n.º 8
0
func main() {
	log.SetPrefix("[plugin gob log] ")

	p := pie.NewProvider()
	if err := p.Register(&test.CI{}); err != nil {
		log.Fatalf("failed to register Plugin: %s", err)
	}
	p.Serve()
}
Exemplo n.º 9
0
func main() {
	log.SetPrefix("[plugin bad (json) log] ")

	p := pie.NewProvider()
	if err := p.Register(&test.CI{}); err != nil {
		log.Fatalf("failed to register Plugin: %s", err)
	}
	fmt.Fprintln(os.Stdout, "bad test")
	p.ServeCodec(jsonrpc.NewServerCodec)
}
Exemplo n.º 10
0
func main() {
	log.SetPrefix("[doit-provider-tag] ")

	p := pie.NewProvider()
	if err := p.RegisterName("tag", api{}); err != nil {
		log.Fatalf("failed to register plugin: %s", err)
	}

	p.ServeCodec(jsonrpc.NewServerCodec)
}
Exemplo n.º 11
0
func main() {
	var differ Differ
	server := pie.NewProvider()
	server.Register(differ)
	server.Serve()
}
Exemplo n.º 12
0
func main() {
	confStr := make([]byte, base64.StdEncoding.DecodedLen(len(os.Args[1])))
	l, _ := base64.StdEncoding.Decode(confStr, []byte(os.Args[1]))

	key, err := ioutil.ReadFile(models.SKYRING_ENC_KEY_FILE)
	if err != nil {
		panic(fmt.Sprintf("Reading enc key failed. error: %v", err))
	}
	cfgs, err := crypto.Decrypt(key, []byte(confStr[:l]))

	var config conf.SkyringCollection
	if err := json.Unmarshal(cfgs, &config); err != nil {
		panic(fmt.Sprintf("Reading configurations failed. error: %v", err))
	}
	conf.SystemConfig = config

	var eventTypes = make(map[string]string)
	if err := json.Unmarshal([]byte(os.Args[2]), &eventTypes); err != nil {
		panic(fmt.Sprintf("Reading event types failed. error: %v", err))
	}
	provider.EventTypes = eventTypes

	var providerConfig conf.ProviderInfo
	if err := json.Unmarshal([]byte(os.Args[3]), &providerConfig); err != nil {
		panic(fmt.Sprintf("Reading provider configurations failed. error: %v", err))
	}
	bigfin_conf.ProviderConfig = providerConfig

	// Initialize the logger
	level, err := logging.LogLevel(config.Logging.Level.String())
	if err != nil {
		level = logging.DEBUG
	}
	if err := logger.Init(
		"bigfin",
		fmt.Sprintf("%s/bigfin.log", filepath.Dir(config.Logging.Filename)),
		true,
		level); err != nil {
		panic(fmt.Sprintf("log init failed. %s", err))
	}

	if err := db.InitDBSession(config.DBConfig); err != nil {
		logger.Get().Fatalf("Unable to initialize DB. error: %v", err)
	}

	//Initialize the DB provider
	if err := provider.InitializeDb(); err != nil {
		logger.Get().Error("Unable to initialize the DB provider: %s", err)
	}

	// Initialize the task manager
	if err := task.InitializeTaskManager(); err != nil {
		logger.Get().Fatalf("Failed to initialize task manager. error: %v", err)
	}

	if err := provider.InitMonitoringManager(); err != nil {
		logger.Get().Fatalf("Error initializing the monitoring manager: %v", err)
	}

	if err := provider.InitInstaller(); err != nil {
		logger.Get().Fatalf("Error initializing the Installer: %v", err)
	}

	schedule.InitShechuleManager()
	if err := provider.ScheduleRbdEventEmitter(); err != nil {
		logger.Get().Error("Error while initializing RbdEventer scheduler: %v", err)
	}

	// Initialize ceph http client
	client.InitCephApiSession()

	provd := &provider.CephProvider{}
	p := pie.NewProvider()
	if err := p.RegisterName(bigfin_conf.ProviderName, provd); err != nil {
		logger.Get().Fatalf("Failed to register plugin. error: %v", err)
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
}