Esempio n. 1
0
/*
Generate a Version 4 UUID as specified in RFC 4122, wrap it in a value
and return it. The UUID() function may return an error, if so return
a nil value UUID with the error.
*/
func (this *Uuid) Evaluate(item value.Value, context Context) (value.Value, error) {
	u, err := util.UUID()
	if err != nil {
		return nil, err
	}
	return value.NewValue(u), nil
}
Esempio n. 2
0
func NewBaseRequest(statement string, prepared *plan.Prepared, namedArgs map[string]value.Value, positionalArgs value.Values,
	namespace string, readonly, metrics, signature value.Tristate, consistency ScanConfiguration,
	client_id string, creds datastore.Credentials) *BaseRequest {
	rv := &BaseRequest{
		statement:      statement,
		prepared:       prepared,
		namedArgs:      namedArgs,
		positionalArgs: positionalArgs,
		namespace:      namespace,
		readonly:       readonly,
		signature:      signature,
		metrics:        metrics,
		consistency:    consistency,
		credentials:    creds,
		requestTime:    time.Now(),
		serviceTime:    time.Now(),
		state:          RUNNING,
		results:        make(value.ValueChannel, RESULT_CAP),
		errors:         make(errors.ErrorChannel, ERROR_CAP),
		warnings:       make(errors.ErrorChannel, ERROR_CAP),
		closeNotify:    make(chan bool, 1),
		stopResult:     make(chan bool, 1),
		stopExecute:    make(chan bool, 1),
	}
	uuid, _ := util.UUID()
	rv.id = &requestIDImpl{id: uuid}
	rv.client_id = newClientContextIDImpl(client_id)
	return rv
}
Esempio n. 3
0
func TestNewV4(t *testing.T) {
	u, err := util.UUID()
	if err != nil {
		t.Errorf("Unexpected error getting UUID: %s", err.Error())
	}
	if !parseUUIDRegex.MatchString(u) {
		t.Errorf("Expected string representation to be valid, given: %s", u)
	}
	fmt.Printf("\t UUID:  %s \n", u)
}