Exemplo n.º 1
0
func ServiceSchedulerTest(tr *TestRunner) {
	Convey("should receive simple task", func() {
		tr.When(sarif.CreateMessage("schedule/duration", map[string]interface{}{
			"duration": "300ms",
		}))

		reply := tr.Expect()
		So(reply, ShouldBeAction, "schedule/created")
	})

	Convey("should receive complex task", func() {
		tr.When(sarif.CreateMessage("schedule/duration", map[string]interface{}{
			"duration": "100ms",
			"reply": sarif.Message{
				Action:      "push/text",
				Destination: tr.Id,
				Text:        "reminder finished",
			},
		}))

		reply := tr.Expect()
		So(reply, ShouldBeAction, "schedule/created")
	})

	Convey("should emit both tasks", func() {
		reply := tr.Expect()
		So(reply, ShouldBeAction, "push/text")
		So(reply.Text, ShouldEqual, "reminder finished")

		reply = tr.Expect()
		So(reply, ShouldBeAction, "schedule/finished")
		So(reply.Text, ShouldStartWith, "Reminder from")
	})
}
Exemplo n.º 2
0
func (s *Service) handlePut(msg sarif.Message) {
	collection, key := parseAction("store/put/", msg.Action)
	if collection == "" {
		s.ReplyBadRequest(msg, errors.New("No collection specified."))
		return
	}

	if len(msg.Payload.Raw) == 0 && msg.Text != "" {
		v, _ := json.Marshal(msg.Text)
		msg.Payload.Raw = json.RawMessage(v)
	}
	var p interface{}
	if err := msg.DecodePayload(&p); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	// TODO: maybe a JSON payload consistency check
	doc, err := s.Store.Put(&Document{
		Collection: collection,
		Key:        key,
		Value:      msg.Payload.Raw,
	})
	if err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	doc.Value = nil
	reply := sarif.CreateMessage("store/updated/"+doc.Collection+"/"+doc.Key, doc)
	s.Reply(msg, reply)

	pub := sarif.CreateMessage("store/updated/"+doc.Collection+"/"+doc.Key, doc)
	s.Publish(pub)
}
Exemplo n.º 3
0
func (s *Service) handleQuery(msg sarif.Message) {
	query := msg.Text

	// Query and wait for first answer
	answers, errs := know.Ask(query)
	ans, ok := <-answers

	if !ok {
		// No answer found? Check for errors.
		err, ok := <-errs
		if !ok {
			// No errors found? Send negative answer
			pl := MessageAnswer{
				Query: query,
			}
			s.Reply(msg, sarif.CreateMessage("knowledge/noanswer", pl))
			return
		}

		// Error received, forward.
		s.ReplyInternalError(msg, err)
		return
	}

	// Send answer.
	pl := MessageAnswer{
		ans.Question,
		ans.Answer,
		ans.Provider,
	}
	s.Reply(msg, sarif.CreateMessage("knowledge/answer", pl))
	return
}
Exemplo n.º 4
0
func ServiceEventsTest(tr *TestRunner) {
	Convey("should store a new event", func() {
		tr.When(sarif.CreateMessage("event/new", map[string]interface{}{
			"action": "user/drink/coffee",
			"text":   "User drinks coffee.",
		}))

		reply := tr.Expect()
		So(reply, ShouldBeAction, "event/created")
	})

	Convey("should store return last event", func() {
		tr.When(sarif.CreateMessage("event/last", map[string]interface{}{
			"action": "user/drink/coffee",
		}))

		reply := tr.Expect()
		So(reply, ShouldBeAction, "event/found")

		payload := Event{}
		reply.DecodePayload(&payload)
		So(payload.Text, ShouldEqual, "User drinks coffee.")
	})

	Convey("should record other messages", func() {
		// Create test events
		tr.When(sarif.CreateMessage("event/record", map[string]interface{}{
			"action": "some/value/changed",
			"time":   time.Now().Add(-100 * time.Minute),
		}))
		So(tr.Expect(), ShouldBeAction, "event/recording")

		tr.When(sarif.Message{
			Action: "some/value/changed",
			Text:   "some value has changed",
		})
		tr.Wait()

		tr.When(sarif.CreateMessage("event/last", map[string]interface{}{
			"action": "some/value/changed",
		}))

		reply := tr.Expect()
		So(reply, ShouldBeAction, "event/found")

		payload := Event{}
		reply.DecodePayload(&payload)
		So(payload.Text, ShouldEqual, "some value has changed")
	})
}
Exemplo n.º 5
0
func (s *Service) handleDel(msg sarif.Message) {
	collection, key := parseAction("store/del/", msg.Action)
	if collection == "" || key == "" {
		s.ReplyBadRequest(msg, errors.New("No collection or key specified."))
		return
	}
	if err := s.Store.Del(collection, key); err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	s.Reply(msg, sarif.CreateMessage("store/deleted/"+collection+"/"+key, nil))
	s.Publish(sarif.CreateMessage("store/deleted/"+collection+"/"+key, nil))
}
Exemplo n.º 6
0
func (s *Service) handleScan(msg sarif.Message) {
	collection, prefix := parseAction("store/scan/", msg.Action)
	if collection == "" {
		s.ReplyBadRequest(msg, errors.New("No collection specified."))
		return
	}

	var p scanMessage
	if err := msg.DecodePayload(&p); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	if p.Start == "" && p.End == "" {
		if p.Prefix == "" {
			p.Prefix = prefix
		}
	}

	got, err := s.doScan(collection, p)
	if err != nil {
		s.ReplyInternalError(msg, err)
		return
	}
	s.Reply(msg, sarif.CreateMessage("store/scanned/"+collection, got))
}
Exemplo n.º 7
0
func (cv *Conversation) handleUnknownUserMessage(msg sarif.Message) {
	pl := &MsgErrNatural{
		Original: msg.Text,
	}

	cv.SendToClient(msg.Reply(sarif.CreateMessage("err/natural", pl)))
}
Exemplo n.º 8
0
func (t *TestRunner) UseConn(conn sarif.Conn) {
	t.conn = conn
	t.Publish(sarif.CreateMessage("proto/sub", map[string]string{
		"device": t.Id,
	}))
	go t.listen()
}
Exemplo n.º 9
0
func (s *Service) handleEventList(msg sarif.Message) {
	var filter map[string]interface{}
	if err := msg.DecodePayload(&filter); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	if filter == nil {
		filter = make(map[string]interface{})
	}
	reverse := false
	if len(filter) == 0 {
		filter["time >="] = time.Now().Add(-24 * time.Hour)
		reverse = true
	}

	s.Log("debug", "list by filter:", filter)
	var events []Event
	err := s.Store.Scan("events", store.Scan{
		Only:    "values",
		Filter:  filter,
		Reverse: reverse,
	}, &events)
	if err != nil {
		s.ReplyInternalError(msg, err)
	}
	s.Log("debug", "list - found", len(events))

	s.Reply(msg, sarif.CreateMessage("events/listed", &aggPayload{
		Type:   "list",
		Filter: filter,
		Events: events,
		Value:  float64(len(events)),
	}))
}
Exemplo n.º 10
0
func (s *Service) HandleQuery(msg sarif.Message) {
	var f Fact
	if err := msg.DecodePayload(&f); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}

	f, err := s.InterpretLiterals(f)
	if err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	var facts []*Fact
	if err := s.DB.Where(f).Limit(100).Find(&facts).Error; err != nil {
		s.ReplyInternalError(msg, err)
		return
	}
	if facts, err = s.AddLabelFacts(facts); err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	s.Reply(msg, sarif.CreateMessage("concepts/result", &resultPayload{
		ToJsonLd(facts),
		facts,
	}))
}
Exemplo n.º 11
0
func (s *Service) HandleQueryExternal(msg sarif.Message) {
	var f Fact
	if err := msg.DecodePayload(&f); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	facts := []*Fact{&f}
	FillVariables(facts)

	var r sparql.ResourceResponse
	q := sparql.DBPedia.Query()
	q = BuildQuery(q, facts)
	if err := q.Exec(&r); err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	result := ApplyBindings(facts, r.Results.Bindings, sparql.CommonPrefixes)
	s.Reply(msg, sarif.CreateMessage("concepts/result", &resultPayload{
		ToJsonLd(result),
		result,
	}))

	for _, f := range result {
		if err := s.DB.FirstOrCreate(&f, &f).Error; err != nil {
			s.Log("err", "[reasoner] error updating external fact: "+err.Error())
		}
	}
}
Exemplo n.º 12
0
func (s *Service) handleCounter(msg sarif.Message) {
	if msg.Text == "" {
		s.ReplyBadRequest(msg, errors.New("Please specify a counter name!"))
		return
	}
	name := msg.Text
	cnt, err := s.counterGet(name)
	if err != nil {
		s.ReplyInternalError(msg, err)
		return
	}
	newCnt := cnt
	if msg.IsAction("cmd/decrement") {
		newCnt--
	} else if msg.IsAction("cmd/increment") {
		newCnt++
	}
	if newCnt != cnt {
		if err := s.counterSet(name, newCnt); err != nil {
			s.ReplyInternalError(msg, err)
			return
		}
	}
	s.Reply(msg, sarif.CreateMessage("counter/changed/"+name, &counterMessage{name, newCnt}))
}
Exemplo n.º 13
0
func (s *Service) handleEventRecord(msg sarif.Message) {
	var p recordPayload
	if err := msg.DecodePayload(&p); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	if p.Action == "" {
		s.ReplyBadRequest(msg, errors.New("No action specified"))
		return
	}

	var cfg Config
	s.cfg.Get(&cfg)
	if cfg.RecordedActions == nil {
		cfg.RecordedActions = make(map[string]bool)
	}
	if enabled := cfg.RecordedActions[p.Action]; !enabled {
		cfg.RecordedActions[p.Action] = true
		s.cfg.Set(cfg)
		s.Subscribe(p.Action, "", s.handleEventNew)
	}

	s.Log("debug", "recording action:", p.Action)
	s.Reply(msg, sarif.CreateMessage("event/recording", p))
}
Exemplo n.º 14
0
func (s *Service) handleAuthOtp(msg sarif.Message) {
	tok := "otp/std:" + GenerateDigits()
	s.SessionTokens[tok] = time.Now().Add(time.Minute)

	s.Reply(msg, sarif.CreateMessage("auth/generated", sarif.ClientInfo{
		Auth: tok,
	}))
}
Exemplo n.º 15
0
func (s *Service) handleLuaLoad(msg sarif.Message) {
	gen := false
	name := strings.TrimPrefix(strings.TrimPrefix(msg.Action, "lua/load"), "/")
	if name == "" {
		name, gen = sarif.GenerateId(), true
	}
	if _, ok := s.Machines[name]; ok {
		s.destroyMachine(name)
	}

	m, err := s.createMachine(name)
	if err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	var ctp ContentPayload
	if err := msg.DecodePayload(&ctp); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	text := msg.Text
	if ctp.Content.Url != "" {
		ct, err := content.Get(ctp.Content)
		if err != nil {
			s.ReplyBadRequest(msg, err)
		}
		text = string(ct.Data)
	}

	var gp interface{}
	msg.DecodePayload(&gp)
	out, err, _ := m.Do(text, gp)
	if err != nil {
		s.ReplyBadRequest(msg, err)
		s.destroyMachine(name)
		return
	}

	if !gen {
		f, err := os.Create(s.cfg.ScriptDir + "/" + name + ".lua")
		if err == nil {
			_, err = f.Write([]byte(text))
			defer f.Close()
		}
		if err != nil {
			s.ReplyInternalError(msg, err)
			s.destroyMachine(name)
			return
		}
	}

	s.Reply(msg, sarif.CreateMessage("lua/loaded", &MsgMachineStatus{
		name,
		"up",
		out,
	}))
}
Exemplo n.º 16
0
func (s *Store) Get(key string, result interface{}) error {
	req := sarif.CreateMessage("store/get/"+key, nil)
	req.Destination = s.StoreName
	reply, ok := <-s.client.Request(req)
	if err := checkErr(reply, ok); err != nil {
		return err
	}
	return reply.DecodePayload(result)
}
Exemplo n.º 17
0
func (s *Scheduler) simpleCron() {
	for {
		now := time.Now()
		nextHour := now.Add(30 * time.Minute).Round(time.Hour)
		time.Sleep(nextHour.Sub(now))
		action := strings.ToLower(time.Now().Add(5 * time.Minute).Format("cron/15h/Mon/2d/1m"))
		s.Publish(sarif.CreateMessage(action, nil))
	}
}
Exemplo n.º 18
0
func (s *Service) handleAuthToken(msg sarif.Message) {
	tok := "token/std:" + sarif.GenerateId() + sarif.GenerateId() + sarif.GenerateId()
	s.Config.Tokens[tok] = true
	s.cfg.Set(s.Config)

	s.Reply(msg, sarif.CreateMessage("auth/generated", sarif.ClientInfo{
		Auth: tok,
	}))
}
Exemplo n.º 19
0
func (s *Service) handleSimple(f func() error) func(sarif.Message) {
	return func(msg sarif.Message) {
		if err := f(); err != nil {
			s.ReplyInternalError(msg, err)
			return
		}
		s.Reply(msg, sarif.CreateMessage("ack/"+msg.Action, nil))
	}
}
Exemplo n.º 20
0
func (s *Service) checkGeofences(last, curr Location) {
	var lastFences, currFences []Geofence
	err := s.Store.Scan("location_geofences", store.Scan{
		Only: "values",
		Filter: map[string]interface{}{
			"lat_min <=": last.Latitude,
			"lat_max >=": last.Latitude,
			"lng_min <=": last.Longitude,
			"lng_max >=": last.Longitude,
		},
	}, &lastFences)
	if err != nil {
		s.Log("err/internal", "retrieve last fences: "+err.Error())
	}
	err = s.Store.Scan("location_geofences", store.Scan{
		Only: "values",
		Filter: map[string]interface{}{
			"lat_min <=": curr.Latitude,
			"lat_max >=": curr.Latitude,
			"lng_min <=": curr.Longitude,
			"lng_max >=": curr.Longitude,
		},
	}, &currFences)
	if err != nil {
		s.Log("err/internal", "retrieve curr fences: "+err.Error())
	}

	for _, g := range lastFences {
		if !fenceInSlice(g, currFences) {
			s.Log("debug", "geofence leave", g)
			pl := GeofenceEventPayload{curr, g, "leave"}
			msg := sarif.CreateMessage("location/fence/leave/"+g.Name, pl)
			s.Publish(msg)
		}
	}
	for _, g := range currFences {
		if !fenceInSlice(g, lastFences) {
			s.Log("debug", "geofence enter", g)
			pl := GeofenceEventPayload{curr, g, "enter"}
			msg := sarif.CreateMessage("location/fence/enter/"+g.Name, pl)
			s.Publish(msg)
		}
	}
}
Exemplo n.º 21
0
func (s *Service) HandleCard(msg sarif.Message) {
	uid := strings.TrimPrefix(msg.Action, "vdir/card/")
	c, ok := s.cards[uid]
	if !ok {
		s.ReplyBadRequest(msg, errors.New("No card with with UID "+uid+" found!"))
		return
	}

	s.Reply(msg, sarif.CreateMessage("vdir/card", c.Card))
}
Exemplo n.º 22
0
func (s *Service) counterSet(name string, cnt int) error {
	ack, ok := <-s.Request(sarif.CreateMessage("store/put/counter/"+name, cnt))
	if !ok {
		return errors.New("Timeout while setting new value")
	}
	if ack.IsAction("err") {
		return errors.New(ack.Text)
	}
	return nil
}
Exemplo n.º 23
0
func (s *Store) Batch(p []Command, result interface{}) error {
	req := sarif.CreateMessage("store/batch", &p)
	req.Destination = s.StoreName
	reply, ok := <-s.client.Request(req)
	if err := checkErr(reply, ok); err != nil {
		return err
	}

	return reply.DecodePayload(result)
}
Exemplo n.º 24
0
func (s *Store) Put(key string, doc interface{}) (*Document, error) {
	res := &Document{}
	req := sarif.CreateMessage("store/put/"+key, doc)
	req.Destination = s.StoreName
	reply, ok := <-s.client.Request(req)
	if err := checkErr(reply, ok); err != nil {
		return nil, err
	}

	return res, reply.DecodePayload(res)
}
Exemplo n.º 25
0
func (s *Scheduler) handle(msg sarif.Message) {
	var t ScheduleMessage
	if err := msg.DecodePayload(&t); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}

	now := time.Now()
	t.Task.Time = now
	if t.Time != "" {
		t.Task.Time = futureTime(util.ParseTime(t.Time, now))
	}
	if t.RandomAfter != "" && t.RandomBefore != "" {
		after := futureTime(util.ParseTime(t.RandomAfter, t.Task.Time))
		before := futureTime(util.ParseTime(t.RandomBefore, t.Task.Time))
		if before.Before(after) {
			after, before = before, after
		}
		maxDur := int64(before.Sub(after))
		ranDur := time.Duration(rand.Int63n(maxDur))
		t.Task.Time = after.Add(ranDur)
	}
	if t.Duration != "" {
		dur, err := util.ParseDuration(t.Duration)
		if err != nil {
			s.ReplyBadRequest(msg, err)
			return
		}
		t.Task.Time = t.Task.Time.Add(dur)
	}
	if t.Task.Reply.Action == "" {
		text := msg.Text
		if text == "" {
			text = "Reminder from " + time.Now().Format(time.RFC3339) + " finished."
		}
		t.Task.Reply = sarif.Message{
			Action:      "schedule/finished",
			Destination: msg.Source,
			Text:        text,
		}
	}
	if t.Task.Reply.CorrId == "" {
		t.Reply.CorrId = msg.Id
	}
	s.Log("info", "new task:", t)

	if _, err := s.Store.Put(t.Task.Key(), &t.Task); err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	go s.recalculateTimer()
	s.Reply(msg, sarif.CreateMessage("schedule/created", t.Task))
}
Exemplo n.º 26
0
func (s *Service) handleServingRecord(msg sarif.Message) {
	var sv Serving
	if err := msg.DecodePayload(&sv); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	size, name := splitSizeName(msg.Text)
	if sv.Size == 0 {
		sv.Size = size
	}
	if sv.Name == "" {
		sv.Name = name
	}
	if sv.Product == nil {
		ps, err := s.findProduct(sv.Name)
		if err != nil {
			s.ReplyBadRequest(msg, err)
			return
		}

		if len(ps) > 1 {
			pList := ""
			for _, p := range ps {
				pList += "\n- " + p.Name
			}
			s.ReplyBadRequest(msg, fmt.Errorf("%d products named %s found.%s", len(ps), sv.Name, pList))
			return
		}
		if len(ps) == 1 {
			sv.Product = &ps[0]
		}
	}
	if sv.AmountWeight <= 0 {
		sv.AmountWeight = Weight(sv.Size) * sv.Product.ServingWeight
	}
	if sv.AmountVolume <= 0 {
		sv.AmountVolume = Volume(sv.Size) * sv.Product.ServingVolume
	}
	if sv.AmountWeight <= 0 && sv.AmountVolume <= 0 {
		s.ReplyBadRequest(msg, errors.New("No serving amount specified."))
		return
	}
	if sv.Time.IsZero() {
		sv.Time = time.Now()
	}

	if err := s.DB.Save(&sv).Error; err != nil {
		s.ReplyInternalError(msg, err)
		return
	}

	s.Reply(msg, sarif.CreateMessage("meal/serving/recorded", &sv))
}
Exemplo n.º 27
0
func (s *Service) handleMockAttachments(msg sarif.Message) {
	s.Log("debug", "received", msg)
	pl := AttachmentPayload{
		Attachments: []schema.Attachment{
			{
				Fallback: "Image of a cat.",
				Title:    "Cat",
				ImageUrl: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gNjUK/9sAQwALCAgKCAcLCgkKDQwLDREcEhEPDxEiGRoUHCkkKyooJCcnLTJANy0wPTAnJzhMOT1DRUhJSCs2T1VORlRAR0hF/9sAQwEMDQ0RDxEhEhIhRS4nLkVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVFRUVF/8AAEQgA+gGQAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwAB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7ds5FAHj5ZU5/QUoZnOAKiHMnNTngDFYnahcBRkmnBwwyKry8yD6VL/yzFKw7kgkAIxViB/n+bp196pR9/rVpaljNeG72fN0BP51pWtyZypdsIMYxXNr0P1rWtzzEO1JaGckdPDdrBgr1Y9PatG0nCxGVjya5uEkxMc8561qx/6uH/e/rWqMJI249oRS3V8cVHMoeR2/4CKkb/XRf57VG/3qsgg8swzjac5q8HMcZOD7VUk/4+4vpVqX/UD8aQEwYxqsgzk8GlMjTKynt1BpAf3KfhRNwOOOasCa3AePC/IQatxMwQEnOKrrwGx6VJbfcFNCLAlVvrSiQMcLVU/xVJB1p3CxaHtThgd800fdopkjwwpWwRUAPI+tP7CgBVJBx2odQcHpTB9+puxoApyjAIxVUAMGywGPSpZT+/I7YqOEDD8CpZRBLAGORwQOCO1QiR84LbgKuMfnFU7cZumzUgK8LE7yeg6D1qNt4gYqvI/WpXJ89uTREcquaQFS2kZEZ3BGeADUwjQqCee5pt31H1NVlZvL6n86LjLBs4nkLYxn0oMKxtwM1HbkkAkk9KtfxU0BD865zgilEQYZU4PqKkl+5TEOFGPWgCMId3PNOKFcEflT+9OboKAI2cEetRqAWwOnpTZeKIu31oAczDPltx6GkViCRnFJc/6wfSoQT5g5oAt7wpGaQygtyeKrTkjoT0pv8I+tMB0hVc/NkUguFjHFMk6t9KptQBNJe4b5QSKja8bP3DUTdabJwI6AP//Z",
			},
		},
	}
	s.Reply(msg, sarif.CreateMessage("mock/attached", pl))
}
Exemplo n.º 28
0
func (s *Service) getConversation(device string) *Conversation {
	cv, ok := s.conversations[device]
	if !ok {
		cv = &Conversation{
			service: s,
			Device:  device,
		}
		s.conversations[device] = cv
		s.Subscribe("", s.DeviceId+"/"+device, s.handleNetworkMessage)
		cv.PublishForClient(sarif.CreateMessage("natural/client/new", nil))
	}
	return cv
}
Exemplo n.º 29
0
func (s *Service) handleLocationUpdate(msg sarif.Message) {
	loc := Location{}
	if err := msg.DecodePayload(&loc); err != nil {
		s.ReplyBadRequest(msg, err)
		return
	}
	if loc.Time.IsZero() {
		loc.Time = time.Now()
	}
	loc.Geohash = EncodeGeohash(loc.Latitude, loc.Longitude, 12)
	s.Log("debug", "store update", loc)

	var last []Location
	err := s.Store.Scan("locations", store.Scan{
		Reverse: true,
		Only:    "values",
		Limit:   1,
	}, &last)
	if err != nil {
		s.Log("err/internal", "retrieve last err: "+err.Error())
	}
	if len(last) > 0 {
		loc.Distance = HaversineDistance(last[0], loc)
		loc.Speed = loc.Distance / loc.Time.Sub(last[0].Time).Seconds()
	}

	if _, err := s.Store.Put(loc.Key(), &loc); err != nil {
		s.ReplyInternalError(msg, err)
	}

	if changed := s.Clusters.Advance(loc); changed {
		c := s.Clusters.Current()
		status := "enter"
		if c.Status != ConfirmedCluster {
			status = "leave"
			c = s.Clusters.LastCompleted()
			s.Clusters.ClearCompleted()
		}

		// TODO: make optional
		if place, err := ReverseGeocode(c.Location); err == nil {
			c.Address = place.Pretty()
		}

		s.Publish(sarif.CreateMessage("location/cluster/"+status, c))
	}

	if len(last) > 0 {
		s.checkGeofences(last[0], loc)
	}
}
Exemplo n.º 30
0
func (s *Service) handleBatch(msg sarif.Message) {
	cmds := make([]BatchCommand, 0)
	if err := msg.DecodePayload(&cmds); err != nil {
		s.ReplyInternalError(msg, err)
		return
	}
	results := make([]interface{}, len(cmds))
	for i, cmd := range cmds {
		collection, key := parseAction("", cmd.Key)
		switch cmd.Type {
		case "put":
			doc, err := s.Store.Put(&Document{
				Collection: collection,
				Key:        key,
				Value:      []byte(cmd.Value),
			})
			if err != nil {
				s.ReplyInternalError(msg, err)
				return
			}
			results[i] = doc
		case "get":
			doc, err := s.Store.Get(collection, key)
			if err != nil {
				s.ReplyInternalError(msg, err)
				return
			}
			results[i] = doc
		case "del":
			if err := s.Store.Del(collection, key); err != nil {
				s.ReplyInternalError(msg, err)
				return
			}
			results[i] = true
		case "scan":
			var p scanMessage
			if err := json.Unmarshal(cmd.Value, &p); err != nil {
				s.ReplyInternalError(msg, err)
				return
			}
			got, err := s.doScan(collection, p)
			if err != nil {
				s.ReplyInternalError(msg, err)
				return
			}
			results[i] = got
		}
	}

	s.Reply(msg, sarif.CreateMessage("store/batched/", results))
}