8 "git.curoverse.com/arvados.git/sdk/go/arvados"
11 // Pull is a request to retrieve a block from a remote server, and
18 // MarshalJSON formats a pull request the way keepstore wants to see
20 func (p Pull) MarshalJSON() ([]byte, error) {
21 type KeepstorePullRequest struct {
22 Locator string `json:"locator"`
23 Servers []string `json:"servers"`
25 return json.Marshal(KeepstorePullRequest{
26 Locator: string(p.SizedDigest[:32]),
27 Servers: []string{p.Source.URLBase()}})
30 // Trash is a request to delete a block.
36 // MarshalJSON formats a trash request the way keepstore wants to see
37 // it, i.e., as a bare locator with no +size hint.
38 func (t Trash) MarshalJSON() ([]byte, error) {
39 type KeepstoreTrashRequest struct {
40 Locator string `json:"locator"`
41 BlockMtime int64 `json:"block_mtime"`
43 return json.Marshal(KeepstoreTrashRequest{
44 Locator: string(t.SizedDigest[:32]),
48 // ChangeSet is a set of change requests that will be sent to a
50 type ChangeSet struct {
56 // AddPull adds a Pull operation.
57 func (cs *ChangeSet) AddPull(p Pull) {
59 cs.Pulls = append(cs.Pulls, p)
63 // AddTrash adds a Trash operation
64 func (cs *ChangeSet) AddTrash(t Trash) {
66 cs.Trashes = append(cs.Trashes, t)
70 // String implements fmt.Stringer.
71 func (cs *ChangeSet) String() string {
73 defer cs.mutex.Unlock()
74 return fmt.Sprintf("ChangeSet{Pulls:%d, Trashes:%d}", len(cs.Pulls), len(cs.Trashes))