vitess.io/vitess@v0.16.2/go/mysql/gtid_set.go (about) 1 /* 2 Copyright 2019 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package mysql 18 19 // GTIDSet represents the set of transactions received or applied by a server. 20 // In some flavors, a single GTID is enough to specify the set of all 21 // transactions that came before it, but in others a more complex structure is 22 // required. 23 // 24 // GTIDSet is wrapped by replication.Position, which is a concrete struct. 25 // When sending a GTIDSet over RPCs, encode/decode it as a string. 26 // Most code outside of this package should use replication.Position rather 27 // than GTIDSet. 28 type GTIDSet interface { 29 // String returns the canonical printed form of the set as expected by a 30 // particular flavor of MySQL. 31 String() string 32 33 // Flavor returns the key under which the corresponding parser function is 34 // registered in the transactionSetParsers map. 35 Flavor() string 36 37 // ContainsGTID returns true if the set contains the specified transaction. 38 ContainsGTID(GTID) bool 39 40 // Contains returns true if the set is a superset of another set. All implementations should return false if 41 // other GTIDSet is not the right concrete type for that flavor. 42 Contains(GTIDSet) bool 43 44 // Equal returns true if the set is equal to another set. 45 Equal(GTIDSet) bool 46 47 // AddGTID returns a new GTIDSet that is expanded to contain the given GTID. 48 AddGTID(GTID) GTIDSet 49 50 // Union returns a union of the receiver GTIDSet and the supplied GTIDSet. 51 Union(GTIDSet) GTIDSet 52 53 // Union returns a union of the receiver GTIDSet and the supplied GTIDSet. 54 Last() string 55 } 56 57 // gtidSetParsers maps flavor names to parser functions. It is used by 58 // ParsePosition(). 59 var gtidSetParsers = make(map[string]func(string) (GTIDSet, error))