Beispiel #1
0
func setup(t *testing.T) *gocql.Session {
	flag.Set("config", "../config.toml")
	core.NewConfig()
	//	if err != nil {
	//		t.Fatal(err.Error())
	//	}
	session := core.NewCassandraWConn()
	//create table
	/*if err := session.Query(`CREATE TABLE IF NOT EXISTS message (owner varchar, sender varchar, id timeuuid, payload varchar, PRIMARY KEY ((owner, sender),id)) WITH CLUSTERING ORDER BY (id DESC)`).Exec(); err != nil {
		t.Log("can not create table message")
		t.Fatal(err.Error())
	}*/
	return session
}
Beispiel #2
0
func AddMessage(msg *Message, payload string) error {
	session := core.NewCassandraWConn()
	return session.Query(addMessage, msg.Receiver, msg.Sender, msg.SenderMessageId, payload).Exec()
}
Beispiel #3
0
func DeleteChatList(chatId string, owner string, chatType int) error {
	session := core.NewCassandraWConn()
	return session.Query(removeChat, chatId, chatId, owner, chatType).Exec()
}
Beispiel #4
0
func UpdateChatLastMessageId(chatId string, lastMessageId string, owner string, chatType int) error {
	session := core.NewCassandraWConn()
	return session.Query(updateChatLastMessageId, lastMessageId, owner, chatType).Exec()
}
Beispiel #5
0
func CreateChat(chatId string, target string, owner string, chatType int) error {
	session := core.NewCassandraWConn()
	return session.Query(createChat, chatId, target, owner, chatType).Exec()
}