func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	// List TABLES
	var l list.ListTables
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	lbody, lcode, lerr := l.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", string(lbody), lcode, lerr)
}
示例#2
0
func main() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// deal with iam, or not
	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tn := "test-godynamo-livetest"
	q := query.NewQuery()
	q.TableName = tn
	q.Select = ep.SELECT_ALL
	k_v1 := fmt.Sprintf("AHashKey%d", 100)
	var kc query.KeyCondition
	kc.AttributeValueList = make([]ep.AttributeValue, 1)
	kc.AttributeValueList[0] = ep.AttributeValue{S: k_v1}
	kc.ComparisonOperator = query.OP_EQ
	q.Limit = 10000
	q.KeyConditions["TheHashKey"] = kc
	json, _ := json.Marshal(q)
	fmt.Printf("JSON:%s\n", string(json))
	body, code, err := q.EndpointReq()
	fmt.Printf("%v\n%v\n%v\n", body, code, err)
}
示例#3
0
func installAll() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// deal with iam, or not
	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	_ = <-iam_ready_chan

	var get1 get_item.Request
	var put1 put_item.Request
	var up1 update_item.Request
	var upt1 update_table.Request
	var del1 delete_item.Request
	var delt1 delete_table.Request
	var batchw1 batch_write_item.Request
	var batchg1 batch_get_item.Request
	var create1 create.Request
	var query1 query.Request
	var scan1 scan.Request
	var desc1 describe_table.Request
	var list1 list_tables.Request
	fmt.Printf("%v%v%v%v%v%v%v%v%v%v%v%v%v", get1, put1, up1, upt1, del1, batchw1, batchg1, create1, delt1, query1, scan1, desc1, list1)

}
示例#4
0
func main() {
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	for i := 1; i <= 300; i++ {
		var get1 get.Request
		get1.TableName = "test-godynamo-livetest"
		get1.Key = make(ep.Item)
		k := fmt.Sprintf("AHashKey%d", i)
		v := fmt.Sprintf("%d", i)
		get1.Key["TheHashKey"] = ep.AttributeValue{S: k}
		get1.Key["TheRangeKey"] = ep.AttributeValue{N: v}
		body, code, err := get1.EndpointReq()
		if err != nil || code != http.StatusOK {
			fmt.Printf("get failed %d %v %s\n", code, err, body)
		}
		fmt.Printf("%s\n", string(body))
	}
}
示例#5
0
func main() {
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	var put1 put.Request
	put1.TableName = "test-godynamo-livetest"
	k := fmt.Sprintf("hk1")
	v := fmt.Sprintf("%v", time.Now().Unix())
	put1.Item = make(ep.Item)
	put1.Item["TheHashKey"] = ep.AttributeValue{S: k}
	put1.Item["TheRangeKey"] = ep.AttributeValue{N: v}
	n := fmt.Sprintf("%v", time.Now().Unix())
	put1.Item["Mtime"] = ep.AttributeValue{N: n}
	put1.Item["SomeJunk"] = ep.AttributeValue{S: "some junk"}
	put1.Item["SomeJunks"] = ep.AttributeValue{SS: []string{"some junk1", "some junk2"}}
	body, code, err := put1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("put failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%s\n", string(body))
}
示例#6
0
文件: bbpd.go 项目: takeshiyako2/bbpd
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	sigchan := make(chan os.Signal, 1)
	signal.Notify(sigchan)
	go sigHandle(sigchan)

	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized, " +
			"invoke with conf_file.Read()")
	} else {
		log.Printf("global conf.Vals initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{conf.Vals.Network.DynamoDB.URL})
	}

	// we must give up the lock on the conf before calling GoIAM below, or it
	// will not be able to mutate the auth params
	using_iam := (conf.Vals.UseIAM == true)
	conf.Vals.ConfLock.RUnlock()

	// the naive "fire and forget" IAM roles initializer and watcher.
	if using_iam {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		iam_ready := <-iam_ready_chan
		if !iam_ready {
			panic("iam is not ready? auth problem")
		}
	} else {
		log.Printf("not using iam, assume credentials hardcoded in conf file")
	}

	log.Printf("starting bbpd...")
	pid := syscall.Getpid()
	e := fmt.Sprintf("induce panic with ctrl-c (kill -2 %v) or graceful termination with kill -[1,3,15] %v", pid, pid)
	log.Printf(e)
	ports := []int{bbpd_const.PORT, bbpd_const.PORT2}
	start_bbpd_err := bbpd_route.StartBBPD(ports)
	if start_bbpd_err == nil {
		// all ports are in use. exit with 0 so our rc system does not
		// respawn the program
		log.Printf("all bbpd ports appear to be in use: exit with code 0")
		os.Exit(0)
	} else {
		// abnormal exit - allow the rc system to try to respawn by returning
		// exit code 1
		log.Printf("bbpd invocation error")
		log.Fatal(start_bbpd_err.Error())
	}
}
func main() {

	// this is the same as put-item-livetest except here we demonstrate using a parameterized conf
	home := os.Getenv("HOME")
	home_conf_file := home + string(os.PathSeparator) + "." + conf.CONF_NAME
	home_conf, home_conf_err := conf_file.ReadConfFile(home_conf_file)
	if home_conf_err != nil {
		panic("cannot read conf from " + home_conf_file)
	}
	home_conf.ConfLock.RLock()
	if home_conf.Initialized == false {
		panic("conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if home_conf.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if home_conf.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	home_conf.ConfLock.RUnlock()

	put1 := put.NewPutItem()
	put1.TableName = "test-godynamo-livetest"
	k := fmt.Sprintf("hk1")
	v := fmt.Sprintf("%v", time.Now().Unix())
	// In simple cases you don't need to call NewAttributeValue
	put1.Item["TheHashKey"] = &attributevalue.AttributeValue{S: k}
	put1.Item["TheRangeKey"] = &attributevalue.AttributeValue{N: v}
	n := fmt.Sprintf("%v", time.Now().Unix())
	put1.Item["Mtime"] = &attributevalue.AttributeValue{N: n}
	put1.Item["SomeJunk"] = &attributevalue.AttributeValue{S: "some junk"}
	// for complex attributevalue instances, call the constructor first
	av := attributevalue.NewAttributeValue()
	av.InsertSS("some junk1")
	av.InsertSS("some junk2")
	put1.Item["SomeJunks"] = av
	av2 := attributevalue.NewAttributeValue()
	av2.InsertL(&attributevalue.AttributeValue{S: "some junk1"})
	av2.InsertL(&attributevalue.AttributeValue{S: "some junk2"})
	put1.Item["JunkL"] = av2
	av3 := attributevalue.NewAttributeValue()
	av3.InsertM("somejunkkey", &attributevalue.AttributeValue{S: "some junk1"})

	body, code, err := put1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("put failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
}
func main() {

	// this is the same as put-item-livetest except here we demonstrate using a parameterized conf
	home := os.Getenv("HOME")
	home_conf_file := home + string(os.PathSeparator) + "." + conf.CONF_NAME
	home_conf, home_conf_err := conf_file.ReadConfFile(home_conf_file)
	if home_conf_err != nil {
		panic("cannot read conf from " + home_conf_file)
	}
	home_conf.ConfLock.RLock()
	if home_conf.Initialized == false {
		panic("conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if home_conf.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if home_conf.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	home_conf.ConfLock.RUnlock()

	put1 := put.NewPutItem()
	put1.TableName = "test-godynamo-livetest"

	k := fmt.Sprintf("hk1000")
	v := fmt.Sprintf("%v", time.Now().Unix())
	put1.Item["TheHashKey"] = &attributevalue.AttributeValue{S: k}
	put1.Item["TheRangeKey"] = &attributevalue.AttributeValue{N: v}

	i := fmt.Sprintf("%v", 1)
	t := fmt.Sprintf("%v", time.Now().Unix())
	put1.Item["UserID"] = &attributevalue.AttributeValue{N: i}
	put1.Item["Timestamp"] = &attributevalue.AttributeValue{N: t}

	// the Token field is a simple string
	put1.Item["Token"] = &attributevalue.AttributeValue{S: "a token"}

	// the Location must be created as a "map"
	location := attributevalue.NewAttributeValue()
	location.InsertM("Latitude", &attributevalue.AttributeValue{N: "120.01"})
	location.InsertM("Longitude", &attributevalue.AttributeValue{N: "50.99"})
	put1.Item["Location"] = location

	body, code, err := put1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("put failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
}
示例#9
0
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	get1 := get.NewGetItem()
	get1.TableName = "test-godynamo-livetest"
	// make sure this item has actually been inserted previously
	get1.Key["TheHashKey"] = &attributevalue.AttributeValue{S: "AHashKey264"}
	get1.Key["TheRangeKey"] = &attributevalue.AttributeValue{N: "264"}
	body, code, err := get1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("get failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

	resp := get.NewResponse()
	um_err := json.Unmarshal([]byte(body), resp)
	if um_err != nil {
		log.Fatal(um_err)
	}
	j, jerr := json.Marshal(resp)
	if jerr != nil {
		log.Fatal(jerr)
	}
	fmt.Printf("RESP:%s\n", string(j))

	// Try converting the Response to a ResponseItemJSON
	c, cerr := resp.ToResponseItemJSON()
	if cerr != nil {
		log.Fatal(cerr)
	}
	jc, jcerr := json.Marshal(c)
	if jcerr != nil {
		log.Fatal(jcerr)
	}
	fmt.Printf("JSON:%s\n", string(jc))
}
示例#10
0
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	put1 := put.NewPutItem()
	put1.TableName = "test-godynamo-livetest"
	k := fmt.Sprintf("hk1")
	v := fmt.Sprintf("%v", time.Now().Unix())
	// In simple cases you don't need to call NewAttributeValue
	put1.Item["TheHashKey"] = &attributevalue.AttributeValue{S: k}
	put1.Item["TheRangeKey"] = &attributevalue.AttributeValue{N: v}
	n := fmt.Sprintf("%v", time.Now().Unix())
	put1.Item["Mtime"] = &attributevalue.AttributeValue{N: n}
	put1.Item["SomeJunk"] = &attributevalue.AttributeValue{S: "some junk"}
	// for complex attributevalue instances, call the constructor first
	av := attributevalue.NewAttributeValue()
	av.InsertSS("some junk1")
	av.InsertSS("some junk2")
	put1.Item["SomeJunks"] = av
	av2 := attributevalue.NewAttributeValue()
	av2.InsertL(&attributevalue.AttributeValue{S: "some junk1"})
	av2.InsertL(&attributevalue.AttributeValue{S: "some junk2"})
	put1.Item["JunkL"] = av2
	av3 := attributevalue.NewAttributeValue()
	av3.InsertM("somejunkkey", &attributevalue.AttributeValue{S: "some junk1"})

	body, code, err := put1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("put failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
}
示例#11
0
func main() {
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	Test1()
	Test2()
}
示例#12
0
func main() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// deal with iam, or not
	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body string

	// DELETE THE TABLE
	var del_table1 delete_table.Request
	del_table1.TableName = tablename1
	_, code, err = del_table1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("fail delete %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	lbody, lcode, lerr := l.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", lbody, lcode, lerr)
}
示例#13
0
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	tn := "test-godynamo-livetest"
	q := query.NewQuery()
	q.TableName = tn
	q.Select = ep.SELECT_ALL
	k_v1 := fmt.Sprintf("AHashKey%d", 100)
	kc := condition.NewCondition()
	kc.AttributeValueList = make([]*attributevalue.AttributeValue, 1)
	kc.AttributeValueList[0] = &attributevalue.AttributeValue{S: k_v1}
	kc.ComparisonOperator = query.OP_EQ
	q.Limit = 10000
	q.KeyConditions["TheHashKey"] = kc
	json, _ := json.Marshal(q)
	fmt.Printf("JSON:%s\n", string(json))
	body, code, err := q.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("query failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n%v\n", string(body), code, err)
}
// this tests "RetryBatchWrite", which does NOT do intelligent splitting and re-assembling
// of requests and responses
func Test1() {
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tn := "test-godynamo-livetest"
	b := batch_write_item.NewBatchWriteItem()
	b.RequestItems[tn] = make([]batch_write_item.RequestInstance, 0)
	for i := 1; i <= 300; i++ {
		var p batch_write_item.PutRequest
		p.Item = make(ep.Item)
		k := fmt.Sprintf("AHashKey%d", i)
		v := fmt.Sprintf("%d", i)
		p.Item["TheHashKey"] = ep.AttributeValue{S: k}
		p.Item["TheRangeKey"] = ep.AttributeValue{N: v}
		p.Item["SomeValue"] = ep.AttributeValue{N: v}
		b.RequestItems[tn] =
			append(b.RequestItems[tn],
				batch_write_item.RequestInstance{PutRequest: &p})
	}
	bs, _ := batch_write_item.Split(*b)
	for _, bsi := range bs {
		body, code, err := bsi.RetryBatchWrite(0)
		if err != nil || code != http.StatusOK {
			fmt.Printf("error: %v\n%v\n%v\n", body, code, err)
		} else {
			fmt.Printf("worked!: %v\n%v\n%v\n", body, code, err)
		}
	}
}
示例#15
0
func main() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// deal with iam, or not
	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body string

	// DELETE AN ITEM
	var del_item1 delete_item.Request
	del_item1.TableName = tablename1
	del_item1.Key = make(ep.Item)
	del_item1.Key["TheHashKey"] = ep.AttributeValue{S: "AHashKey1"}
	del_item1.Key["TheRangeKey"] = ep.AttributeValue{N: "1"}

	_, code, err = del_item1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("fail delete %d %v %s\n", code, err, body)
		os.Exit(1)
	}
}
示例#16
0
func installAll() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	var get1 get_item.Request
	var put1 put_item.Request
	var up1 update_item.Request
	var upt1 update_table.Request
	var del1 delete_item.Request
	var delt1 delete_table.Request
	var batchw1 batch_write_item.Request
	var batchg1 batch_get_item.Request
	var create1 create.Request
	var query1 query.Request
	var scan1 scan.Request
	var desc1 describe_table.Request
	var list1 list_tables.Request
	fmt.Printf("%v%v%v%v%v%v%v%v%v%v%v%v%v", get1, put1, up1, upt1, del1, batchw1, batchg1, create1, delt1, query1, scan1, desc1, list1)
}
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	Test1()
	Test2()
}
示例#18
0
func main() {
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tablename1 := "test-godynamo-livetest"
	fmt.Printf("tablename: %s\n", tablename1)

	var code int
	var err error
	var body string

	// CREATE TABLE
	var create1 create.Create
	create1.TableName = tablename1
	create1.ProvisionedThroughput.ReadCapacityUnits = 100
	create1.ProvisionedThroughput.WriteCapacityUnits = 100
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		ep.AttributeDefinition{AttributeName: "TheHashKey", AttributeType: ep.S})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		ep.AttributeDefinition{AttributeName: "TheRangeKey", AttributeType: ep.N})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		ep.AttributeDefinition{AttributeName: "AnAttrName", AttributeType: ep.S})
	create1.KeySchema = append(create1.KeySchema,
		ep.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	create1.KeySchema = append(create1.KeySchema,
		ep.KeyDefinition{AttributeName: "TheRangeKey", KeyType: ep.RANGE})
	lsi := ep.NewLocalSecondaryIndex()
	lsi.IndexName = "AnAttrIndex"
	lsi.Projection.ProjectionType = ep.KEYS_ONLY
	lsi.KeySchema = append(lsi.KeySchema,
		ep.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	lsi.KeySchema = append(lsi.KeySchema,
		ep.KeyDefinition{AttributeName: "AnAttrName", KeyType: ep.RANGE})
	create1.LocalSecondaryIndexes = append(create1.LocalSecondaryIndexes, *lsi)

	create_json, create_json_err := json.Marshal(create1)
	if create_json_err != nil {
		fmt.Printf("%v\n", create_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(create_json))
	fmt.Printf("%v\n", create1)

	cbody, ccode, cerr := create1.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", cbody, ccode, cerr)

	var desc1 desc.Describe
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	fmt.Printf("desc:%v\n%v\n,%v\n", body, code, err)

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err := desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	lbody, lcode, lerr := l.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", lbody, lcode, lerr)

}
func main() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// deal with iam, or not
	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body string

	// INSERT SINGLE ITEM
	hk := "a-hash-key"
	rk := "1"
	var put1 put_item.Request
	put1.TableName = tablename1
	var av1, av2, av3, av4, av5, av6, av7 ep.AttributeValue
	av1.S = hk
	av2.N = rk
	av3.SS = []string{"pk1_a", "pk1_b", "pk1_c"}
	av4.NS = []string{"1", "2", "3", "-7.234234234234234e+09"}
	av5.N = "1"
	av6.B = base64.StdEncoding.EncodeToString([]byte("hello"))
	av7.BS = []string{base64.StdEncoding.EncodeToString([]byte("hello")),
		base64.StdEncoding.EncodeToString([]byte("there"))}
	put1.Item = make(ep.Item)
	put1.Item["TheHashKey"] = av1
	put1.Item["TheRangeKey"] = av2
	put1.Item["stringlist"] = av3
	put1.Item["numlist"] = av4
	put1.Item["num"] = av5
	put1.Item["byte"] = av6
	put1.Item["bytelist"] = av7
	// recommended to make sure pk does not exist yet in table
	// (i.e. this will be a new item)
	put1.Expected = make(ep.Expected)
	put1.Expected["t1.hk"] = ep.Constraints{Exists: false}
	body, code, err = put1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("put1 failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	// GET THAT ITEM
	var get1 get_item.Request
	get1.TableName = tablename1
	get1.Key = make(ep.Item)
	get1.Key["TheHashKey"] = av1
	get1.Key["TheRangeKey"] = av2

	get_json, get_json_err := json.Marshal(get1)
	if get_json_err != nil {
		fmt.Printf("%v\n", get_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(get_json))

	body, code, err = get1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("get failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}
	var gr get_item.Response
	um_err := json.Unmarshal([]byte(body), &gr)
	if um_err != nil {
		fmt.Printf("get resp unmarshal failed %s\n", um_err.Error())
		os.Exit(1)
	}

	// USE PUT TO REPLACE THAT ITEM CONDITIONALLY
	// **SET IT UP TO FAIL**
	var put2 put_item.Request
	put2.TableName = tablename1
	var av1_2, av2_2, av3_2, av4_2, av5_2, av6_2 ep.AttributeValue
	av1_2.S = hk
	av2_2.N = rk
	av3_2.SS = []string{"pk1_d", "pk1_e", "pk1_f"}
	av4_2.NS = []string{"4", "5", "6"}
	av5_2.N = "2"
	av6_2.S = "hello there"
	put2.Item = make(ep.Item)
	put2.Item["TheHashKey"] = av1_2
	put2.Item["TheRangeKey"] = av2_2
	put2.Item["stringlist"] = av3_2
	put2.Item["numlist"] = av4_2
	put2.Item["num"] = av5_2
	put2.Item["string"] = av6_2
	put2.Item["byte"] = av6
	put2.Item["bytelist"] = av7
	put2.Expected = make(ep.Expected)
	put2.Expected["TheHashKey"] = ep.Constraints{Exists: false}
	body, code, err = put2.EndpointReq()
	if err == nil && code == http.StatusOK {
		fmt.Printf("put2 should have failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	// NOW MAKE IT SO THAT PUT WORKS
	put2.Expected = make(ep.Expected)
	put2.ReturnValues = put_item.RETVAL_ALL_OLD
	put2.Expected["num"] = ep.Constraints{Exists: true, Value: av5}
	body, code, err = put2.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("put2 item failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	// UPDATE THAT ITEM
	var up1 update_item.Request
	new_attr_val := "new string here"
	up1.TableName = tablename1
	up1.Key = make(ep.Item)
	up1.Key["TheHashKey"] = av1
	up1.Key["TheRangeKey"] = av2

	up1.AttributeUpdates = make(update_item.AttributeUpdates)
	up1.AttributeUpdates["new_string"] =
		update_item.AttributeAction{Value: ep.AttributeValue{S: new_attr_val}, Action: update_item.ACTION_PUT}
	var del_stringlist ep.AttributeValue
	del_stringlist.SS = []string{"pk1_a"}
	up1.AttributeUpdates["stringlist"] =
		update_item.AttributeAction{Value: del_stringlist, Action: update_item.ACTION_DEL}
	up1.AttributeUpdates["byte"] = update_item.AttributeAction{Value: ep.AttributeValue{}, Action: update_item.ACTION_DEL}
	up1.AttributeUpdates["num"] = update_item.AttributeAction{Value: ep.AttributeValue{N: "4"}, Action: update_item.ACTION_ADD}
	up1.ReturnValues = update_item.RETVAL_ALL_NEW

	update_item_json, update_item_json_err := json.Marshal(up1)
	if update_item_json_err != nil {
		fmt.Printf("%v\n", update_item_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(update_item_json))

	body, code, err = up1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("update item failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	var ur update_item.Response
	um_err = json.Unmarshal([]byte(body), &ur)
	if um_err != nil {
		fmt.Printf("update resp unmarshal failed %s\n", um_err.Error())
		os.Exit(1)
	}

	// GET IT AGAIN
	body, code, err = get1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("get failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	// DELETE THE ITEM
	var del1 delete_item.Request
	del1.Key = make(ep.Item)
	del1.TableName = tablename1
	del1.Key["TheHashKey"] = av1
	del1.Key["TheRangeKey"] = av2

	del1.Expected = make(ep.Expected)
	del1.Expected["num"] = ep.Constraints{Exists: true, Value: ep.AttributeValue{N: "6"}}
	del1.ReturnValues = delete_item.RETVAL_ALL_OLD
	body, code, err = del1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("delete item failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}
}
示例#20
0
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	s := scan.NewScan()
	tn := "test-godynamo-livetest"
	s.TableName = tn
	k_v1 := fmt.Sprintf("AHashKey%d", 100)

	kc := condition.NewCondition()
	kc.AttributeValueList = make([]*attributevalue.AttributeValue, 1)
	kc.AttributeValueList[0] = &attributevalue.AttributeValue{S: k_v1}
	kc.ComparisonOperator = scan.OP_EQ

	s.ScanFilter["TheHashKey"] = kc
	jsonstr, _ := json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err := s.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("scan failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n%v\n", string(body), code, err)

	var r scan.Response
	um_err := json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}

	s = scan.NewScan()
	s.TableName = tn
	jsonstr, _ = json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err = s.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("scan failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n%v\n", string(body), code, err)

	um_err = json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}

	kc = condition.NewCondition()
	kc.AttributeValueList = make([]*attributevalue.AttributeValue, 2)
	kc.AttributeValueList[0] = &attributevalue.AttributeValue{N: "270"}
	kc.AttributeValueList[1] = &attributevalue.AttributeValue{N: "290"}
	kc.ComparisonOperator = scan.OP_BETWEEN
	s.ScanFilter["SomeValue"] = kc

	jsonstr, _ = json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err = s.EndpointReq()
	fmt.Printf("%v\n%v\n%v\n", string(body), code, err)
	um_err = json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}
	k_v2 := fmt.Sprintf("AHashKey%d", 290)
	r_v2 := fmt.Sprintf("%d", 290)
	s.ExclusiveStartKey["TheHashKey"] = &attributevalue.AttributeValue{S: k_v2}
	s.ExclusiveStartKey["TheRangeKey"] = &attributevalue.AttributeValue{N: r_v2}
	jsonstr, _ = json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err = s.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("scan failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n%v\n", string(body), code, err)

	um_err = json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}
}
示例#21
0
func main() {
	// conf file must be read in before anything else, to initialize permissions etc
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// deal with iam, or not
	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body string

	var update_table1 update_table.Request
	update_table1.TableName = tablename1
	update_table1.ProvisionedThroughput.ReadCapacityUnits = 200
	update_table1.ProvisionedThroughput.WriteCapacityUnits = 200
	body, code, err = update_table1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("update table failed %d %v %s\n", code, err, body)
		os.Exit(1)
	}

	// WAIT FOR THE PROVISIONING TO FINISH
	fmt.Printf("checking for ACTIVE status for update....\n")
	active, poll_err := desc.PollTableStatus(tablename1,
		desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	var desc1 desc.Describe
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	fmt.Printf("desc:%v\n%v\n,%v\n", body, code, err)

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err = desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	lbody, lcode, lerr := l.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", lbody, lcode, lerr)

}
func main() {

	// this is the same as get-item-livetest except here we demonstrate using a parameterized conf
	home := os.Getenv("HOME")
	home_conf_file := home + string(os.PathSeparator) + "." + conf.CONF_NAME
	home_conf, home_conf_err := conf_file.ReadConfFile(home_conf_file)
	if home_conf_err != nil {
		panic("cannot read conf from " + home_conf_file)
	}
	home_conf.ConfLock.RLock()
	if home_conf.Initialized == false {
		panic("conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if home_conf.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if home_conf.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	home_conf.ConfLock.RUnlock()

	get1 := get.NewGetItem()
	get1.TableName = "test-godynamo-livetest"
	// make sure this item has actually been inserted previously
	get1.Key["TheHashKey"] = &attributevalue.AttributeValue{S: "AHashKey264"}
	get1.Key["TheRangeKey"] = &attributevalue.AttributeValue{N: "264"}
	body, code, err := get1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("get failed %d %v %s\n", code, err, body)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

	resp := get.NewResponse()
	um_err := json.Unmarshal([]byte(body), resp)
	if um_err != nil {
		log.Fatal(um_err)
	}
	j, jerr := json.Marshal(resp)
	if jerr != nil {
		log.Fatal(jerr)
	}
	fmt.Printf("RESP:%s\n", string(j))

	// Try converting the Response to a ResponseItemJSON
	c, cerr := resp.ToResponseItemJSON()
	if cerr != nil {
		log.Fatal(cerr)
	}
	jc, jcerr := json.Marshal(c)
	if jcerr != nil {
		log.Fatal(jcerr)
	}
	fmt.Printf("JSON:%s\n", string(jc))
}
示例#23
0
func main() {
	conf_file.Read()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	iam_ready_chan := make(chan bool)
	go conf_iam.GoIAM(iam_ready_chan)
	iam_ready := <-iam_ready_chan
	if iam_ready {
		fmt.Printf("using iam\n")
	} else {
		fmt.Printf("not using iam\n")
	}

	s := scan.NewScan()
	tn := "test-godynamo-livetest"
	s.TableName = tn
	k_v1 := fmt.Sprintf("AHashKey%d", 100)
	s.ScanFilter["TheHashKey"] =
		scan.ScanFilter{AttributeValueList: []ep.AttributeValue{ep.AttributeValue{S: k_v1}},
			ComparisonOperator: scan.OP_EQ}
	jsonstr, _ := json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err := s.EndpointReq()
	var r scan.Response
	um_err := json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}

	fmt.Printf("%v\n%v\n%v\n", body, code, err)
	s = scan.NewScan()
	s.TableName = tn
	jsonstr, _ = json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err = s.EndpointReq()
	fmt.Printf("%v\n%v\n%v\n", body, code, err)
	um_err = json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}

	s.ScanFilter["SomeValue"] =
		scan.ScanFilter{AttributeValueList: []ep.AttributeValue{
			ep.AttributeValue{N: "270"}, ep.AttributeValue{N: "290"}},
			ComparisonOperator: scan.OP_BETWEEN}
	jsonstr, _ = json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err = s.EndpointReq()
	fmt.Printf("%v\n%v\n%v\n", body, code, err)
	um_err = json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}
	k_v2 := fmt.Sprintf("AHashKey%d", 290)
	r_v2 := fmt.Sprintf("%d", 290)
	s.ExclusiveStartKey["TheHashKey"] = ep.AttributeValue{S: k_v2}
	s.ExclusiveStartKey["TheRangeKey"] = ep.AttributeValue{N: r_v2}
	jsonstr, _ = json.Marshal(s)
	fmt.Printf("JSON:%s\n", string(jsonstr))
	body, code, err = s.EndpointReq()
	fmt.Printf("%v\n%v\n%v\n", body, code, err)
	um_err = json.Unmarshal([]byte(body), &r)
	if um_err != nil {
		e := fmt.Sprintf("unmarshal Response: %v", um_err)
		fmt.Printf("%s\n", e)
	}
}
func main() {

	// this is the same as item-operations-livetest except here we demonstrate using a parameterized conf
	home := os.Getenv("HOME")
	home_conf_file := home + string(os.PathSeparator) + "." + conf.CONF_NAME
	home_conf, home_conf_err := conf_file.ReadConfFile(home_conf_file)
	if home_conf_err != nil {
		panic("cannot read conf from " + home_conf_file)
	}
	home_conf.ConfLock.RLock()
	if home_conf.Initialized == false {
		panic("conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if home_conf.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if home_conf.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	home_conf.ConfLock.RUnlock()

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body []byte

	// INSERT SINGLE ITEM
	hk := "a-hash-key"
	rk := "1"
	put1 := put_item.NewPutItem()
	put1.TableName = tablename1
	av1 := attributevalue.NewAttributeValue()
	av2 := attributevalue.NewAttributeValue()
	av3 := attributevalue.NewAttributeValue()
	av4 := attributevalue.NewAttributeValue()
	av5 := attributevalue.NewAttributeValue()
	av6 := attributevalue.NewAttributeValue()
	av7 := attributevalue.NewAttributeValue()
	av1.S = hk
	av2.N = rk
	av3.InsertSS("pk1_a")
	av3.InsertSS("pk1_c")
	av4.InsertNS("1")
	av4.InsertNS_float64(2)
	av4.InsertNS("3")
	av4.InsertNS("-7.2432342")
	av5.N = "1"
	av6.B = base64.StdEncoding.EncodeToString([]byte("hello"))
	av7.InsertBS(base64.StdEncoding.EncodeToString([]byte("hello")))
	av7.InsertBS(base64.StdEncoding.EncodeToString([]byte("there")))
	put1.Item["TheHashKey"] = av1
	put1.Item["TheRangeKey"] = av2
	put1.Item["stringlist"] = av3
	put1.Item["numlist"] = av4
	put1.Item["num"] = av5
	put1.Item["byte"] = av6
	put1.Item["bytelist"] = av7

	body, code, err = put1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("put1 failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

	// GET THAT ITEM
	get1 := get_item.NewGetItem()
	get1.TableName = tablename1
	get1.Key["TheHashKey"] = av1
	get1.Key["TheRangeKey"] = av2

	get_json, get_json_err := json.Marshal(get1)
	if get_json_err != nil {
		fmt.Printf("%v\n", get_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(get_json))

	body, code, err = get1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("get failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

	var gr get_item.Response
	um_err := json.Unmarshal([]byte(body), &gr)
	if um_err != nil {
		fmt.Printf("get resp unmarshal failed %s\n", um_err.Error())
		os.Exit(1)
	}
	fmt.Printf("%v\n", string(body))

	// UPDATE THAT ITEM
	up1 := update_item.NewUpdateItem()
	new_attr_val := "new string here"
	up1.TableName = tablename1
	up1.Key["TheHashKey"] = av1
	up1.Key["TheRangeKey"] = av2

	up1.AttributeUpdates = attributevalue.NewAttributeValueUpdateMap()
	up_avu := attributevalue.NewAttributeValueUpdate()
	up_avu.Action = update_item.ACTION_PUT
	up_avu.Value = &attributevalue.AttributeValue{S: new_attr_val}
	up1.AttributeUpdates["new_string"] = up_avu

	del_avu := attributevalue.NewAttributeValueUpdate()
	del_avu.Action = update_item.ACTION_DEL
	del_avu.Value = attributevalue.NewAttributeValue()
	del_avu.Value.InsertSS("pk1_a")
	up1.AttributeUpdates["stringlist"] = del_avu

	del2_avu := attributevalue.NewAttributeValueUpdate()
	del2_avu.Action = update_item.ACTION_DEL
	del2_avu.Value = &attributevalue.AttributeValue{}
	up1.AttributeUpdates["byte"] = del2_avu

	add_avu := attributevalue.NewAttributeValueUpdate()
	add_avu.Action = update_item.ACTION_ADD
	add_avu.Value = &attributevalue.AttributeValue{N: "4"}
	up1.AttributeUpdates["num"] = add_avu

	up1.ReturnValues = update_item.RETVAL_ALL_NEW

	update_item_json, update_item_json_err := json.Marshal(up1)
	if update_item_json_err != nil {
		fmt.Printf("%v\n", update_item_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(update_item_json))

	body, code, err = up1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("update item failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

	var ur update_item.Response
	um_err = json.Unmarshal([]byte(body), &ur)
	if um_err != nil {
		fmt.Printf("update resp unmarshal failed %s\n", um_err.Error())
		os.Exit(1)
	}

	// GET IT AGAIN
	body, code, err = get1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("get failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

	// DELETE THE ITEM
	del1 := delete_item.NewDeleteItem()
	del1.TableName = tablename1
	del1.Key["TheHashKey"] = av1
	del1.Key["TheRangeKey"] = av2

	del1.ReturnValues = delete_item.RETVAL_ALL_OLD
	body, code, err = del1.EndpointReqWithConf(home_conf)
	if err != nil || code != http.StatusOK {
		fmt.Printf("delete item failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

	fmt.Printf("PASSED\n")
}
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	tn := "test-godynamo-livetest"
	tablename1 := tn
	fmt.Printf("tablename1: %s\n", tablename1)

	var code int
	var err error
	var body []byte

	update_table1 := update_table.NewUpdateTable()
	update_table1.TableName = tablename1
	update_table1.ProvisionedThroughput.ReadCapacityUnits = 200
	update_table1.ProvisionedThroughput.WriteCapacityUnits = 200
	body, code, err = update_table1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("update table failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}

	// WAIT FOR THE PROVISIONING TO FINISH
	fmt.Printf("checking for ACTIVE status for update....\n")
	active, poll_err := desc.PollTableStatus(tablename1,
		desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	var desc1 desc.DescribeTable
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("desc failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("desc:%v\n%v\n,%v\n", string(body), code, err)

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err = desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	body, code, err = l.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("list failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)

}
func main() {
	conf_file.Read()
	conf.Vals.ConfLock.RLock()
	if conf.Vals.Initialized == false {
		panic("the conf.Vals global conf struct has not been initialized")
	}

	// launch a background poller to keep conns to aws alive
	if conf.Vals.Network.DynamoDB.KeepAlive {
		log.Printf("launching background keepalive")
		go keepalive.KeepAlive([]string{})
	}

	// deal with iam, or not
	if conf.Vals.UseIAM {
		iam_ready_chan := make(chan bool)
		go conf_iam.GoIAM(iam_ready_chan)
		_ = <-iam_ready_chan
	}
	conf.Vals.ConfLock.RUnlock()

	tablename1 := "test-godynamo-livetest"
	fmt.Printf("tablename: %s\n", tablename1)

	var code int
	var err error
	var body []byte

	// CREATE TABLE
	create1 := create.NewCreateTable()
	create1.TableName = tablename1
	create1.ProvisionedThroughput.ReadCapacityUnits = 100
	create1.ProvisionedThroughput.WriteCapacityUnits = 100

	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		attributedefinition.AttributeDefinition{AttributeName: "TheHashKey", AttributeType: ep.S})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		attributedefinition.AttributeDefinition{AttributeName: "TheRangeKey", AttributeType: ep.N})
	create1.AttributeDefinitions = append(create1.AttributeDefinitions,
		attributedefinition.AttributeDefinition{AttributeName: "AnAttrName", AttributeType: ep.S})
	create1.KeySchema = append(create1.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	create1.KeySchema = append(create1.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "TheRangeKey", KeyType: ep.RANGE})

	lsi := localsecondaryindex.NewLocalSecondaryIndex()
	lsi.IndexName = "AnAttrIndex"
	lsi.Projection.ProjectionType = aws_strings.KEYS_ONLY
	lsi.KeySchema = append(lsi.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "TheHashKey", KeyType: ep.HASH})
	lsi.KeySchema = append(lsi.KeySchema,
		keydefinition.KeyDefinition{AttributeName: "AnAttrName", KeyType: ep.RANGE})
	create1.LocalSecondaryIndexes = append(create1.LocalSecondaryIndexes, *lsi)

	create_json, create_json_err := json.Marshal(create1)
	if create_json_err != nil {
		fmt.Printf("%v\n", create_json_err)
		os.Exit(1)
	}
	fmt.Printf("%s\n", string(create_json))
	fmt.Printf("%v\n", create1)

	body, code, err = create1.EndpointReq()
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
	if err != nil || code != http.StatusOK {
		fmt.Printf("create failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}

	var desc1 desc.Describe
	desc1.TableName = tablename1
	body, code, err = desc1.EndpointReq()
	fmt.Printf("desc:%v\n%v\n,%v\n", string(body), code, err)
	if err != nil || code != http.StatusOK {
		fmt.Printf("desc failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}

	// WAIT FOR IT TO BE ACTIVE
	fmt.Printf("checking for ACTIVE status for table....\n")
	active, poll_err := desc.PollTableStatus(tablename1, desc.ACTIVE, 100)
	if poll_err != nil {
		fmt.Printf("poll1:%v\n", poll_err)
		os.Exit(1)
	}
	fmt.Printf("ACTIVE:%v\n", active)

	// List TABLES
	var l list.List
	l.ExclusiveStartTableName = ""
	l.Limit = 100
	body, code, err = l.EndpointReq()
	if err != nil || code != http.StatusOK {
		fmt.Printf("list failed %d %v %s\n", code, err, string(body))
		os.Exit(1)
	}
	fmt.Printf("%v\n%v\n,%v\n", string(body), code, err)
}