zhangmeng
2020-01-20 accc3295d6daacd70494ecd3a08033f505c29f66
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package master
 
import (
    "analysis/app"
    "analysis/logo"
    "plugin"
 
    "basic.com/valib/pubsub.git"
)
 
// Fetcher db
type Fetcher struct {
    fnInit func(string, string, int, []string, string) (chan pubsub.Message, error)
}
 
// NewFetcher new
func NewFetcher(soFile string) *Fetcher {
 
    plug, err := plugin.Open(soFile)
    if err != nil {
        logo.Errorln("Open: ", soFile, " error: ", err)
        return nil
    }
 
    fn, err := app.LoadFunc(plug, soFile, "Init")
    if err != nil {
        logo.Infoln("Lookup Func Init From File: ", soFile, " Error")
        return nil
    }
    fnInit := fn.(func(string, string, int, []string, string) (chan pubsub.Message, error))
 
    return &Fetcher{
        fnInit: fnInit,
    }
}