-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodel.go
42 lines (33 loc) · 860 Bytes
/
model.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
package main
import "github.com/hazelcast/hazelcast-go-client/serialization"
type Reading struct {
Name string
Timestamp int64
}
const (
readingClassID = 1
portableFactorID = 1
)
func (d *Reading) ClassID() int32 {
return readingClassID
}
func (d *Reading) FactoryID() int32 {
return portableFactorID
}
func (d *Reading) WritePortable(writer serialization.PortableWriter) error {
writer.WriteUTF("Name", d.Name)
writer.WriteInt64("Timestamp", d.Timestamp)
return nil
}
func (d *Reading) ReadPortable(reader serialization.PortableReader) error {
d.Name = reader.ReadUTF("Name")
d.Timestamp = reader.ReadInt64("Timestamp")
return reader.Error()
}
type ReadingPortableFactory struct{}
func (pf *ReadingPortableFactory) Create(classID int32) serialization.Portable {
if classID == readingClassID {
return &Reading{}
}
return nil
}