forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.go
36 lines (27 loc) · 761 Bytes
/
format.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
package jsonstream
import (
"encoding/json"
)
// Formater define the data's format via stream transfer.
type Formater interface {
// BeginWrite write some data at the stream beginning.
BeginWrite() ([]byte, error)
// EndWrite write some data at the stream ending.
EndWrite() ([]byte, error)
// Write write a object be serialized.
Write(o interface{}) ([]byte, error)
}
// defaultFormat define the pouch's pull progress.
type defaultFormat struct{}
func newDefaultFormat() Formater {
return &defaultFormat{}
}
func (f *defaultFormat) BeginWrite() ([]byte, error) {
return nil, nil
}
func (f *defaultFormat) EndWrite() ([]byte, error) {
return nil, nil
}
func (f *defaultFormat) Write(o interface{}) ([]byte, error) {
return json.Marshal(o)
}