Jelajahi Sumber

Added godocs

Ben Hood 11 tahun lalu
induk
melakukan
1113314503
3 mengubah file dengan 13 tambahan dan 0 penghapusan
  1. 3 0
      cassandra_test.go
  2. 1 0
      conn.go
  3. 9 0
      session.go

+ 3 - 0
cassandra_test.go

@@ -552,6 +552,7 @@ func TestScanCASWithNilArguments(t *testing.T) {
 	}
 }
 
+//TestStaticQueryInfo makes sure that the application can manually bind query parameters using the simplest possible static binding strategy
 func TestStaticQueryInfo(t *testing.T) {
 	session := createSession(t)
 	defer session.Close()
@@ -619,6 +620,7 @@ func upcaseInitial(str string) string {
 	return ""
 }
 
+//TestBoundQueryInfo makes sure that the application can manually bind query parameters using the query meta data supplied at runtime
 func TestBoundQueryInfo(t *testing.T) {
 
 	session := createSession(t)
@@ -657,6 +659,7 @@ func TestBoundQueryInfo(t *testing.T) {
 
 }
 
+//TestBatchQueryInfo makes sure that the application can manually bind query parameters when executing in a batch
 func TestBatchQueryInfo(t *testing.T) {
 
 	if *flagProto == 1 {

+ 1 - 0
conn.go

@@ -641,6 +641,7 @@ func (c *Conn) setKeepalive(d time.Duration) error {
 	return nil
 }
 
+// QueryInfo represents the meta data associated with a prepared CQL statement.
 type QueryInfo struct {
 	id   []byte
 	args []ColumnInfo

+ 9 - 0
session.go

@@ -90,6 +90,12 @@ func (s *Session) Query(stmt string, values ...interface{}) *Query {
 	return qry
 }
 
+// Bind generates a new query object based on the query statement passed in.
+// The query is automatically prepared if it has not previously been executed.
+// The binding callback allows the application to define which query argument
+// values will be marshalled as part of the query execution.
+// During execution, the meta data of the prepared query will be routed to the
+// binding callback, which is responsible for producing the query argument values.
 func (s *Session) Bind(stmt string, b func(q *QueryInfo) ([]interface{}, error)) *Query {
 	s.mu.RLock()
 	qry := &Query{stmt: stmt, binding: b, cons: s.cons,
@@ -405,6 +411,9 @@ func (b *Batch) Query(stmt string, args ...interface{}) {
 	b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, Args: args})
 }
 
+// Bind adds the query to the batch operation and correlates it with a binding callback
+// that will be invoked when the batch is executed. The binding callback allows the application
+// to define which query argument values will be marshalled as part of the batch execution.
 func (b *Batch) Bind(stmt string, bind func(q *QueryInfo) ([]interface{}, error)) {
 	b.Entries = append(b.Entries, BatchEntry{Stmt: stmt, binding: bind})
 }