// APIVersion determines the runtime behavior the fdb package. If the requested // version is not supported by both the fdb package and the FoundationDB C // library, an error will be returned. APIVersion must be called prior to any // other functions in the fdb package. // // Currently, this package supports API versions 200 and 300. func APIVersion(version int) error { networkMutex.Lock() defer networkMutex.Unlock() if apiVersion != 0 { if apiVersion == version { return nil } return errAPIVersionAlreadySet } if version < 200 || version > 300 { return errAPIVersionNotSupported } if e := C.fdb_select_api_version_impl(C.int(version), 300); e != 0 { if e == 2203 && version == 200 { e = C.fdb_select_api_version_impl(C.int(version), 200) } if e != 0 { if e == 2203 { return fmt.Errorf("API version %d not supported by the installed FoundationDB C library", version) } return Error{int(e)} } } apiVersion = version return nil }
// APIVersion determines the runtime behavior the fdb package. If the requested // version is not supported by both the fdb package and the FoundationDB C // library, an error will be returned. APIVersion must be called prior to any // other functions in the fdb package. // // Currently, the only API versions 100 and 101 are supported. func APIVersion(version int) error { networkMutex.Lock() defer networkMutex.Unlock() if apiVersion != 0 { return errorApiVersionAlreadySet } if version < 100 || version > 101 { return errorApiVersionNotSupported } if e := C.fdb_select_api_version_impl(C.int(version), 101); e != 0 { return Error(e) } apiVersion = version return nil }