-
Notifications
You must be signed in to change notification settings - Fork 16
/
event.go
47 lines (38 loc) · 981 Bytes
/
event.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
package notebook
import (
"encoding/json"
"time"
"github.com/Bio-OS/bioos/pkg/schema"
)
const (
ImportNotebooks = "ImportNotebooks"
)
type ImportNotebooksEvent struct {
WorkspaceID string
Schema schema.NotebookTypedSchema
ImportFileBaseDir string
}
func NewImportNotebooksEvent(workspaceID, baseDir string, schema schema.NotebookTypedSchema) *ImportNotebooksEvent {
return &ImportNotebooksEvent{
WorkspaceID: workspaceID,
Schema: schema,
ImportFileBaseDir: baseDir,
}
}
func (e *ImportNotebooksEvent) EventType() string {
return ImportNotebooks
}
func (e *ImportNotebooksEvent) Payload() []byte {
payload, _ := json.Marshal(e)
return payload
}
func (e *ImportNotebooksEvent) Delay() time.Duration {
return 0
}
func NewImportNotebooksEventFromPayload(data []byte) (*ImportNotebooksEvent, error) {
ret := &ImportNotebooksEvent{}
if err := json.Unmarshal(data, ret); err != nil {
return nil, err
}
return ret, nil
}