Example #1
0
func (this *SkyOutput) Init(config *conf.Conf) {
	const TYPE_SEP = ":"
	this.uidFieldType, this.actionFieldType = als.KEY_TYPE_INT, als.KEY_TYPE_STRING
	this.uidField = config.String("uid_field", "_log_info.uid")
	if strings.Contains(this.uidField, TYPE_SEP) {
		p := strings.SplitN(this.uidField, TYPE_SEP, 2)
		this.uidField, this.uidFieldType = p[0], p[1]
	}
	this.actionField = config.String("action_field", "action")
	if this.actionField == "" {
		panic("empty action field")
	}
	if strings.Contains(this.actionField, TYPE_SEP) {
		p := strings.SplitN(this.actionField, TYPE_SEP, 2)
		this.actionField, this.actionFieldType = p[0], p[1]
	}

	this.project = config.String("project", "")
	var (
		host string = config.String("host", "localhost")
		port int    = config.Int("port", 8585)
	)
	client := sky.NewClient(host)
	client.Port = port

	if !client.Ping() {
		panic(fmt.Sprintf("sky server not running: %s:%d", host, port))
	}

	this.table, _ = client.GetTable(config.String("table", ""))
	if this.table == nil {
		panic("must create table in advance")
	}

}
Example #2
0
func main() {
	var (
		fn   string
		host string
		port int
	)
	flag.StringVar(&fn, "c", "tables.cf", "config filename")
	flag.StringVar(&host, "h", "localhost", "sky server address")
	flag.IntVar(&port, "p", 8585, "sky server port")
	flag.Parse()

	if err := loadConfig(fn); err != nil {
		panic(err)
	}

	client := sky.NewClient(host)
	client.Port = port
	if !client.Ping() {
		panic("server is down")
	}

	for _, t := range allTables {
		table, _ := client.GetTable(t.name)
		if table == nil {
			createTable(client, t)
		}
	}

}