• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang proto.MustParseGTID函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/youtube/vitess/go/vt/mysqlctl/proto.MustParseGTID函数的典型用法代码示例。如果您正苦于以下问题:Golang MustParseGTID函数的具体用法?Golang MustParseGTID怎么用?Golang MustParseGTID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MustParseGTID函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestKeyRangeFilterPass

func TestKeyRangeFilterPass(t *testing.T) {
	input := proto.BinlogTransaction{
		Statements: []proto.Statement{
			{
				Category: proto.BL_SET,
				Sql:      []byte("set1"),
			}, {
				Category: proto.BL_DML,
				Sql:      []byte("dml1 /* EMD keyspace_id:20 */"),
			}, {
				Category: proto.BL_DML,
				Sql:      []byte("dml2 /* EMD keyspace_id:2 */"),
			},
		},
		GTIDField: myproto.GTIDField{Value: myproto.MustParseGTID("MariaDB", "0-41983-1")},
	}
	var got string
	f := KeyRangeFilterFunc(key.KIT_UINT64, testKeyRange, func(reply *proto.BinlogTransaction) error {
		got = bltToString(reply)
		return nil
	})
	f(&input)
	want := `statement: <6, "set1"> statement: <4, "dml2 /* EMD keyspace_id:2 */"> position: "0-41983-1" `
	if want != got {
		t.Errorf("want %s, got %s", want, got)
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:27,代码来源:keyrange_filter_test.go


示例2: TestKeyRangeFilterMalformed

func TestKeyRangeFilterMalformed(t *testing.T) {
	input := proto.BinlogTransaction{
		Statements: []proto.Statement{
			{
				Category: proto.BL_SET,
				Sql:      []byte("set1"),
			}, {
				Category: proto.BL_DML,
				Sql:      []byte("ddl"),
			}, {
				Category: proto.BL_DML,
				Sql:      []byte("dml1 /* EMD keyspace_id:20*/"),
			}, {
				Category: proto.BL_DML,
				Sql:      []byte("dml1 /* EMD keyspace_id:2a */"),
			},
		},
		GTIDField: myproto.GTIDField{Value: myproto.MustParseGTID(blsMysqlFlavor, "41983-1")},
	}
	var got string
	f := KeyRangeFilterFunc(key.KIT_UINT64, testKeyRange, func(reply *proto.BinlogTransaction) error {
		got = bltToString(reply)
		return nil
	})
	f(&input)
	want := `position: "41983-1" `
	if want != got {
		t.Errorf("want %s, got %s", want, got)
	}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:30,代码来源:keyrange_filter_test.go


示例3: TestUpdateBlpCheckpointTimestamp

func TestUpdateBlpCheckpointTimestamp(t *testing.T) {
	gtid := myproto.MustParseGTID("MariaDB", "0-2-582")
	want := "UPDATE _vt.blp_checkpoint " +
		"SET pos='MariaDB/0-2-582', time_updated=88822, transaction_timestamp=481828 " +
		"WHERE source_shard_uid=78522"

	got := UpdateBlpCheckpoint(78522, myproto.ReplicationPosition{GTIDSet: gtid.GTIDSet()}, 88822, 481828)
	if got != want {
		t.Errorf("UpdateBlpCheckpoint() = %#v, want %#v", got, want)
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:11,代码来源:binlog_player_test.go


示例4: TestPopulateBlpCheckpoint

func TestPopulateBlpCheckpoint(t *testing.T) {
	gtid := myproto.MustParseGTID("MariaDB", "0-1-1083")
	want := "INSERT INTO _vt.blp_checkpoint " +
		"(source_shard_uid, pos, time_updated, transaction_timestamp, flags) " +
		"VALUES (18372, 'MariaDB/0-1-1083', 481823, 0, 'myflags')"

	got := PopulateBlpCheckpoint(18372, myproto.ReplicationPosition{GTIDSet: gtid.GTIDSet()}, 481823, "myflags")
	if got != want {
		t.Errorf("PopulateBlpCheckpoint() = %#v, want %#v", got, want)
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:11,代码来源:binlog_player_test.go


示例5: TestUpdateBlpCheckpoint

func TestUpdateBlpCheckpoint(t *testing.T) {
	gtid := myproto.MustParseGTID("GoogleMysql", "41983-58283")
	want := "UPDATE _vt.blp_checkpoint " +
		"SET pos='GoogleMysql/41983-58283', time_updated=88822 " +
		"WHERE source_shard_uid=78522"

	got := UpdateBlpCheckpoint(78522, myproto.ReplicationPosition{GTIDSet: gtid.GTIDSet()}, 88822, 0)
	if got != want {
		t.Errorf("UpdateBlpCheckpoint() = %#v, want %#v", got, want)
	}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:11,代码来源:binlog_player_test.go


示例6: TestUpdateBlpCheckpointTimestamp

func TestUpdateBlpCheckpointTimestamp(t *testing.T) {
	gtid := myproto.MustParseGTID("GoogleMysql", "58283")
	want := "UPDATE _vt.blp_checkpoint " +
		"SET gtid='GoogleMysql/58283', time_updated=88822, transaction_timestamp=481828 " +
		"WHERE source_shard_uid=78522"

	got := UpdateBlpCheckpoint(78522, gtid, 88822, 481828)
	if got != want {
		t.Errorf("UpdateBlpCheckpoint() = %#v, want %#v", got, want)
	}
}
开发者ID:ninqing,项目名称:vitess,代码行数:11,代码来源:binlog_player_test.go


示例7: TestPopulateBlpCheckpoint

func TestPopulateBlpCheckpoint(t *testing.T) {
	gtid := myproto.MustParseGTID("GoogleMysql", "19283")
	want := "INSERT INTO _vt.blp_checkpoint " +
		"(source_shard_uid, gtid, time_updated, transaction_timestamp, flags) " +
		"VALUES (18372, 'GoogleMysql/19283', 481823, 0, 'myflags')"

	got := PopulateBlpCheckpoint(18372, gtid, 481823, "myflags")
	if got != want {
		t.Errorf("PopulateBlpCheckpoint() = %#v, want %#v", got, want)
	}
}
开发者ID:ninqing,项目名称:vitess,代码行数:11,代码来源:binlog_player_test.go


示例8: TestDMLEvent

func TestDMLEvent(t *testing.T) {
	trans := &proto.BinlogTransaction{
		Statements: []proto.Statement{
			{
				Category: proto.BL_SET,
				Sql:      []byte("SET TIMESTAMP=2"),
			}, {
				Category: proto.BL_SET,
				Sql:      []byte("SET INSERT_ID=10"),
			}, {
				Category: proto.BL_DML,
				Sql:      []byte("query /* _stream vtocc_e (eid id name)  (null -1 'bmFtZQ==' ) (null 18446744073709551615 'bmFtZQ==' ); */"),
			}, {
				Category: proto.BL_DML,
				Sql:      []byte("query"),
			},
		},
		Timestamp: 1,
		GTIDField: myproto.GTIDField{Value: myproto.MustParseGTID("MariaDB", "0-41983-20")},
	}
	evs := &EventStreamer{
		sendEvent: func(event *proto.StreamEvent) error {
			switch event.Category {
			case "DML":
				want := `&{DML vtocc_e [eid id name] [[10 -1 [110 97 109 101]] [11 18446744073709551615 [110 97 109 101]]]  1 <nil>}`
				got := fmt.Sprintf("%v", event)
				if got != want {
					t.Errorf("got \n%s, want \n%s", got, want)
				}
			case "ERR":
				want := `&{ERR  [] [] query 1 <nil>}`
				got := fmt.Sprintf("%v", event)
				if got != want {
					t.Errorf("got %s, want %s", got, want)
				}
			case "POS":
				want := `&{POS  [] []  1 0-41983-20}`
				got := fmt.Sprintf("%v", event)
				if got != want {
					t.Errorf("got %s, want %s", got, want)
				}
			default:
				t.Errorf("unexppected: %#v", event)
			}
			return nil
		},
	}
	err := evs.transactionToEvent(trans)
	if err != nil {
		t.Error(err)
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:52,代码来源:event_streamer_test.go


示例9: nextStatement

// nextStatement returns the next statement encountered in the binlog stream. If there are
// positional comments, it updates the binlogFileStreamer state. It also ignores events that
// are not material. If it returns nil, it's the end of stream. If err is also nil, then
// it was due to a normal termination.
func (bls *binlogFileStreamer) nextStatement(ctx *sync2.ServiceContext, bufReader *bufio.Reader) (stmt []byte, err error) {
eventLoop:
	for {
		// Stop processing if we're shutting down
		if !ctx.IsRunning() {
			return nil, io.EOF
		}
		event, err := bls.readEvent(bufReader)
		if err != nil {
			if err == io.EOF {
				return nil, nil
			}
			return nil, err
		}
		values := posRE.FindSubmatch(event)
		if values != nil {
			bls.blPos.ServerId = mustParseInt64(values[1])
			bls.file.Set(mustParseInt64(values[2]))

			// Make the fake Google GTID format we invented.
			gtid := string(values[1]) + "-" + string(values[3])
			bls.blPos.GTID = myproto.MustParseGTID(blsMysqlFlavor, gtid)
			continue
		}
		values = rotateRE.FindSubmatch(event)
		if values != nil {
			err = bls.file.Rotate(path.Join(bls.dir, string(values[1])), mustParseInt64(values[2]))
			if err != nil {
				return nil, err
			}
			return nil, nil
		}
		if bytes.HasPrefix(event, eolfPrefix) {
			return nil, nil
		}
		values = delimRE.FindSubmatch(event)
		if values != nil {
			bls.delim = values[1]
			continue
		}
		for _, ignorePrefix := range ignorePrefixes {
			if bytes.HasPrefix(event, ignorePrefix) {
				continue eventLoop
			}
		}
		return event, nil
	}
}
开发者ID:chinna1986,项目名称:vitess,代码行数:52,代码来源:binlog_file_streamer.go


示例10: TestDDLEvent

func TestDDLEvent(t *testing.T) {
	trans := &proto.BinlogTransaction{
		Statements: []proto.Statement{
			{
				Category: proto.BL_SET,
				Sql:      []byte("SET TIMESTAMP=2"),
			}, {
				Category: proto.BL_DDL,
				Sql:      []byte("DDL"),
			},
		},
		Timestamp: 1,
		GTIDField: myproto.GTIDField{Value: myproto.MustParseGTID("MariaDB", "0-41983-20")},
	}
	evs := &EventStreamer{
		sendEvent: func(event *proto.StreamEvent) error {
			switch event.Category {
			case "DDL":
				want := `&{DDL  [] [] DDL 1 <nil>}`
				got := fmt.Sprintf("%v", event)
				if got != want {
					t.Errorf("got %s, want %s", got, want)
				}
			case "POS":
				want := `&{POS  [] []  1 0-41983-20}`
				got := fmt.Sprintf("%v", event)
				if got != want {
					t.Errorf("got %s, want %s", got, want)
				}
			default:
				t.Errorf("unexppected: %#v", event)
			}
			return nil
		},
	}
	err := evs.transactionToEvent(trans)
	if err != nil {
		t.Error(err)
	}
}
开发者ID:pranjal5215,项目名称:vitess,代码行数:40,代码来源:event_streamer_test.go



注:本文中的github.com/youtube/vitess/go/vt/mysqlctl/proto.MustParseGTID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang proto.ProtoToReplicationPosition函数代码示例发布时间:2022-05-28
下一篇:
Golang proto.EncodeReplicationPosition函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap