1 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 2 // use this file except in compliance with the License. You may obtain a copy of 3 // the License at 4 // 5 // http://www.apache.org/licenses/LICENSE-2.0 6 // 7 // Unless required by applicable law or agreed to in writing, software 8 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 9 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10 // License for the specific language governing permissions and limitations under 11 // the License. 12 13 package driver 14 15 import "context" 16 17 // DBUpdate represents a database update event. 18 type DBUpdate struct { 19 DBName string `json:"db_name"` 20 Type string `json:"type"` 21 Seq string `json:"seq"` 22 } 23 24 // DBUpdates is a DBUpdates iterator. 25 type DBUpdates interface { 26 // Next is called to populate DBUpdate with the values of the next update in 27 // the feed. 28 // 29 // Next should return [io.EOF] when the feed is closed normally. 30 Next(*DBUpdate) error 31 // Close closes the iterator. 32 Close() error 33 } 34 35 // LastSeqer extends the [DBUpdates] interface, and in Kivik v5, will be 36 // included in it. 37 type LastSeqer interface { 38 // LastSeq returns the last sequence ID reported. 39 LastSeq() (string, error) 40 } 41 42 // DBUpdater is an optional interface that may be implemented by a 43 // [Client] to provide access to the DB Updates feed. 44 type DBUpdater interface { 45 // DBUpdates must return a [DBUpdates] iterator. The context, or the iterator's 46 // Close method, may be used to close the iterator. 47 DBUpdates(ctx context.Context, options Options) (DBUpdates, error) 48 } 49