/
streams.go
51 lines (44 loc) · 1012 Bytes
/
streams.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"github.com/256dpi/xo"
"github.com/256dpi/fire/axe"
"github.com/256dpi/fire/blaze"
"github.com/256dpi/fire/coal"
"github.com/256dpi/fire/glut"
"github.com/256dpi/fire/spark"
)
func itemStream(store *coal.Store) *spark.Stream {
return &spark.Stream{
Model: &Item{},
Store: store,
Validator: func(sub *spark.Subscription) error {
// check state
if _, ok := sub.Data["state"].(bool); !ok {
return xo.SF("invalid state")
}
return nil
},
Selector: func(event *spark.Event, sub *spark.Subscription) bool {
return event.Model.(*Item).State == sub.Data["state"].(bool)
},
SoftDelete: true,
}
}
func jobStream(store *coal.Store) *spark.Stream {
return &spark.Stream{
Model: &axe.Model{},
Store: store,
}
}
func valueStream(store *coal.Store) *spark.Stream {
return &spark.Stream{
Model: &glut.Model{},
Store: store,
}
}
func fileStream(store *coal.Store) *spark.Stream {
return &spark.Stream{
Model: &blaze.File{},
Store: store,
}
}