Documentation ¶
Overview ¶
Example ¶
store := ops.Polled(testops.MemStore(nil)) defer store.Close() handler := &nw.Handler{Store: store} srv := httptest.NewServer(handler) defer srv.Close() c := nw.Client{URL: srv.URL, Client: srv.Client()} defer c.Close() op1 := ops.Operation{OpID: "ID1", ParentID: "", VerID: 100, BasisID: -1} op2 := ops.Operation{OpID: "ID2", ParentID: "ID1", VerID: 100, BasisID: -1, Change: changes.ChangeSet{changes.Move{Offset: 1, Count: 2, Distance: 3}}} ctx := getContext() if err := c.Append(ctx, []ops.Op{op1}); err != nil { fmt.Println("Append1", err) return } if err := c.Append(ctx, []ops.Op{op2}); err != nil { fmt.Println("Append2", err) return } ops, err := c.GetSince(ctx, 0, 100) fmt.Println("Ops", ops, err)
Output: Ops [{ID1 0 -1 <nil>} {ID2 ID1 1 -1 [{1 2 3}]}] <nil>
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultCodecs = map[string]Codec{ "application/x-gob": gobCodec{}, "application/x-sjson": sjson.Std, }
DefaultCodecs is the default codecs list which contains a map of content-type to codec.
Functions ¶
Types ¶
type Client ¶
type Client struct { URL string Header map[string]string ContentType string Codecs map[string]Codec log.Log *http.Client }
Client implements the ops.Store interface by making network calls to the provided Url. All other fields of the Client are optional.
type Codec ¶
type Codec interface { Encode(value interface{}, writer io.Writer) error Decode(value interface{}, reader io.Reader) error Register(v interface{}) }
Codec is the interface codecs will have to implement to marshal and unmarshal requests and responses
Click to show internal directories.
Click to hide internal directories.