diff --git a/.gitignore b/.gitignore index 7227f5f440d..242b01dc181 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ packaging/msi/FDBInstaller.msi *.g.S *.g.asm *.pom -bindings/go/src/fdb/generated.go bindings/java/pom*.xml bindings/java/src*/main/overview.html bindings/java/src*/main/com/apple/foundationdb/*Options.java diff --git a/Makefile b/Makefile index 55bc077bf91..cfba0e6601e 100644 --- a/Makefile +++ b/Makefile @@ -174,13 +174,13 @@ lib/libstdc++.a: $(shell $(CC) -print-file-name=libstdc++_pic.a) @ar rcs $@ .libstdc++/*.o @rm -r .libstdc++ -docpreview: javadoc godoc +docpreview: javadoc TARGETS= $(MAKE) -C documentation docpreview docpreview_clean: CLEAN_TARGETS= $(MAKE) -C documentation docpreview_clean -packages/foundationdb-docs-$(VERSION).tar.gz: FORCE javadoc godoc +packages/foundationdb-docs-$(VERSION).tar.gz: FORCE javadoc TARGETS= $(MAKE) -C documentation docpackage @mkdir -p packages @rm -f packages/foundationdb-docs-$(VERSION).tar.gz diff --git a/bindings/go/README.md b/bindings/go/README.md index f4c5a25348a..15beef47ed5 100644 --- a/bindings/go/README.md +++ b/bindings/go/README.md @@ -27,5 +27,5 @@ of downloading from the remote repository. Documentation ------------- -* [API documentation](https://www.foundationdb.org/documentation/godoc/fdb.html) +* [API documentation](https://godoc.org/github.com/apple/foundationdb/bindings/go/src/fdb) * [Tutorial](https://www.foundationdb.org/documentation/class-scheduling-go.html) diff --git a/bindings/go/include.mk b/bindings/go/include.mk index d56669b0843..358404309e0 100644 --- a/bindings/go/include.mk +++ b/bindings/go/include.mk @@ -25,7 +25,7 @@ GOPATH := $(CURDIR)/bindings/go/build GO_IMPORT_PATH := github.com/apple/foundationdb/bindings/go/src GO_DEST := $(GOPATH)/src/$(GO_IMPORT_PATH) -.PHONY: fdb_go fdb_go_path fdb_go_fmt fdb_go_fmt_check fdb_go_tester fdb_go_tester_clean godoc godoc_clean +.PHONY: fdb_go fdb_go_path fdb_go_fmt fdb_go_fmt_check fdb_go_tester fdb_go_tester_clean # We only override if the environment didn't set it (this is used by # the fdbwebsite documentation build process) @@ -47,7 +47,8 @@ GO_PACKAGE_OUTDIR := $(GOPATH)/pkg/$(GOPLATFORM)/$(GO_IMPORT_PATH) GO_PACKAGES := fdb fdb/tuple fdb/subspace fdb/directory GO_PACKAGE_OBJECTS := $(addprefix $(GO_PACKAGE_OUTDIR)/,$(GO_PACKAGES:=.a)) -GO_SRC := $(shell find $(CURDIR)/bindings/go/src -name '*.go') +GO_GEN := $(CURDIR)/bindings/go/src/fdb/generated.go +GO_SRC := $(shell find $(CURDIR)/bindings/go/src -name '*.go') $(GO_GEN) fdb_go: $(GO_PACKAGE_OBJECTS) $(GO_SRC) fdb_go_fmt_check @@ -77,53 +78,26 @@ fdb_go_tester_clean: @echo "Cleaning fdb_go_tester" @rm -rf $(GOPATH)/bin -$(GOPATH)/bin/_stacktester: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OBJECTS) $(GO_DEST)/fdb/generated.go +$(GOPATH)/bin/_stacktester: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OBJECTS) @echo "Compiling $(basename $(notdir $@))" @go install $(GO_IMPORT_PATH)/_stacktester -$(GO_PACKAGE_OUTDIR)/fdb/tuple.a: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OUTDIR)/fdb.a $(GO_DEST)/fdb/generated.go +$(GO_PACKAGE_OUTDIR)/fdb/tuple.a: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OUTDIR)/fdb.a @echo "Compiling fdb/tuple" @go install $(GO_IMPORT_PATH)/fdb/tuple -$(GO_PACKAGE_OUTDIR)/fdb/subspace.a: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OUTDIR)/fdb.a $(GO_PACKAGE_OUTDIR)/fdb/tuple.a $(GO_DEST)/fdb/generated.go +$(GO_PACKAGE_OUTDIR)/fdb/subspace.a: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OUTDIR)/fdb.a $(GO_PACKAGE_OUTDIR)/fdb/tuple.a @echo "Compiling fdb/subspace" @go install $(GO_IMPORT_PATH)/fdb/subspace -$(GO_PACKAGE_OUTDIR)/fdb/directory.a: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OUTDIR)/fdb.a $(GO_PACKAGE_OUTDIR)/fdb/tuple.a $(GO_PACKAGE_OUTDIR)/fdb/subspace.a $(GO_DEST)/fdb/generated.go +$(GO_PACKAGE_OUTDIR)/fdb/directory.a: $(GO_DEST)/.stamp $(GO_SRC) $(GO_PACKAGE_OUTDIR)/fdb.a $(GO_PACKAGE_OUTDIR)/fdb/tuple.a $(GO_PACKAGE_OUTDIR)/fdb/subspace.a @echo "Compiling fdb/directory" @go install $(GO_IMPORT_PATH)/fdb/directory -$(GO_PACKAGE_OUTDIR)/fdb.a: $(GO_DEST)/.stamp lib/libfdb_c.$(DLEXT) $(GO_SRC) $(GO_DEST)/fdb/generated.go +$(GO_PACKAGE_OUTDIR)/fdb.a: $(GO_DEST)/.stamp lib/libfdb_c.$(DLEXT) $(GO_SRC) @echo "Compiling fdb" @go install $(GO_IMPORT_PATH)/fdb -$(GO_DEST)/fdb/generated.go: $(GO_DEST)/.stamp bindings/go/src/_util/translate_fdb_options.go fdbclient/vexillographer/fdb.options +$(GO_GEN): bindings/go/src/_util/translate_fdb_options.go fdbclient/vexillographer/fdb.options @echo "Building $@" @go run bindings/go/src/_util/translate_fdb_options.go < fdbclient/vexillographer/fdb.options > $@ - -godoc: fdb_go_path $(GO_SRC) $(GO_DEST)/fdb/generated.go - @echo "Generating Go Documentation" - @rm -rf $(GODOC_DIR)/godoc - @mkdir -p $(GODOC_DIR)/godoc - @mkdir -p $(GODOC_DIR)/godoc/lib/godoc - @godoc -url "pkg/$(GO_IMPORT_PATH)/fdb" > $(GODOC_DIR)/godoc/fdb.html - @godoc -url "pkg/$(GO_IMPORT_PATH)/fdb/tuple" > $(GODOC_DIR)/godoc/fdb.tuple.html - @godoc -url "pkg/$(GO_IMPORT_PATH)/fdb/subspace" > $(GODOC_DIR)/godoc/fdb.subspace.html - @godoc -url "pkg/$(GO_IMPORT_PATH)/fdb/directory" > $(GODOC_DIR)/godoc/fdb.directory.html - @cp $(CURDIR)/bindings/go/godoc-resources/* $(GODOC_DIR)/godoc/lib/godoc - @echo "Mangling paths in Go Documentation" - @(find $(GODOC_DIR)/godoc/ -name *.html -exec sed -i '' -e 's_/lib_lib_' {} \;) - @(sed -i -e 's_a href="tuple/"_a href="fdb.tuple.html"_' $(GODOC_DIR)/godoc/fdb.html) - @(sed -i -e 's_a href="subspace/"_a href="fdb.subspace.html"_' $(GODOC_DIR)/godoc/fdb.html) - @(sed -i -e 's_a href="directory/"_a href="fdb.directory.html"_' $(GODOC_DIR)/godoc/fdb.html) - - @(sed -i -e 's_a href="/pkg/builtin_a href="https://godoc.org/pkg/builtin_g;s_a href="/src/github.com/apple/foundationdb_a href="https://github.com/apple/foundationdb/tree/master_g;s_a href="/pkg/github.com/apple/foundationdb/bindings/go/src/fdb/_a href="./fdb.html_g' $(GODOC_DIR)/godoc/fdb.html) - @(sed -i -e 's_a href="/pkg/builtin_a href="https://godoc.org/pkg/builtin_g;s_a href="/src/github.com/apple/foundationdb_a href="https://github.com/apple/foundationdb/tree/master_g;s_a href="/pkg/github.com/apple/foundationdb/bindings/go/src/fdb/_a href="./fdb.html_g' $(GODOC_DIR)/godoc/fdb.directory.html) - @(sed -i -e 's_a href="/pkg/builtin_a href="https://godoc.org/pkg/builtin_g;s_a href="/src/github.com/apple/foundationdb_a href="https://github.com/apple/foundationdb/tree/master_g;s_a href="/pkg/github.com/apple/foundationdb/bindings/go/src/fdb/_a href="./fdb.html_g' $(GODOC_DIR)/godoc/fdb.subspace.html) - @(sed -i -e 's_a href="/pkg/builtin_a href="https://godoc.org/pkg/builtin_g;s_a href="/src/github.com/apple/foundationdb_a href="https://github.com/apple/foundationdb/tree/master_g;s_a href="/pkg/github.com/apple/foundationdb/bindings/go/src/fdb/_a href="./fdb.html_g' $(GODOC_DIR)/godoc/fdb.tuple.html) - - -godoc_clean: - @echo "Cleaning Go Documentation" - @rm -rf $(GODOC_DIR)/godoc - diff --git a/bindings/go/src/_util/translate_fdb_options.go b/bindings/go/src/_util/translate_fdb_options.go index 63d694a3a8b..2f96d5e491d 100644 --- a/bindings/go/src/_util/translate_fdb_options.go +++ b/bindings/go/src/_util/translate_fdb_options.go @@ -136,7 +136,7 @@ func (t Transaction) %s(key KeyConvertible, param []byte) { func writeEnum(scope Scope, opt Option, delta int) { fmt.Println() if opt.Description != "" { - doc.ToText(os.Stdout, opt.Description, " // ", "", 73) + doc.ToText(os.Stdout, opt.Description, "\t// ", "", 73) // fmt.Printf(" // %s\n", opt.Description) } fmt.Printf(" %s %s = %d\n", scope.Name+translateName(opt.Name), scope.Name, opt.Code+delta) @@ -157,14 +157,34 @@ func main() { log.Fatal(err) } - fmt.Print(`// DO NOT EDIT THIS FILE BY HAND. This file was generated using -// translate_fdb_options.go, part of the fdb-go repository, and a copy of the -// fdb.options file (installed as part of the FoundationDB client, typically + fmt.Print(`/* + * generated.go + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// DO NOT EDIT THIS FILE BY HAND. This file was generated using +// translate_fdb_options.go, part of the FoundationDB repository, and a copy of +// the fdb.options file (installed as part of the FoundationDB client, typically // found as /usr/include/foundationdb/fdb.options). -// To regenerate this file, from the top level of an fdb-go repository checkout, -// run: -// $ go run _util/translate_fdb_options.go < /usr/include/foundationdb/fdb.options > fdb/generated.go +// To regenerate this file, from the top level of a FoundationDB repository +// checkout, run: +// $ go run bindings/go/src/_util/translate_fdb_options.go < fdbclient/vexillographer/fdb.options > bindings/go/src/fdb/generated.go package fdb @@ -216,6 +236,7 @@ func int64ToBytes(i int64) ([]byte, error) { fmt.Printf(` type %s int + const ( `, scope.Name) for _, opt := range scope.Option { diff --git a/bindings/go/src/fdb/generated.go b/bindings/go/src/fdb/generated.go new file mode 100644 index 00000000000..a3d842d6231 --- /dev/null +++ b/bindings/go/src/fdb/generated.go @@ -0,0 +1,514 @@ +/* + * generated.go + * + * This source file is part of the FoundationDB open source project + * + * Copyright 2013-2018 Apple Inc. and the FoundationDB project authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// DO NOT EDIT THIS FILE BY HAND. This file was generated using +// translate_fdb_options.go, part of the FoundationDB repository, and a copy of +// the fdb.options file (installed as part of the FoundationDB client, typically +// found as /usr/include/foundationdb/fdb.options). + +// To regenerate this file, from the top level of a FoundationDB repository +// checkout, run: +// $ go run bindings/go/src/_util/translate_fdb_options.go < fdbclient/vexillographer/fdb.options > bindings/go/src/fdb/generated.go + +package fdb + +import ( + "bytes" + "encoding/binary" +) + +func int64ToBytes(i int64) ([]byte, error) { + buf := new(bytes.Buffer) + if e := binary.Write(buf, binary.LittleEndian, i); e != nil { + return nil, e + } + return buf.Bytes(), nil +} + +// Enables trace output to a file in a directory of the clients choosing +// +// Parameter: path to output directory (or NULL for current working directory) +func (o NetworkOptions) SetTraceEnable(param string) error { + return o.setOpt(30, []byte(param)) +} + +// Sets the maximum size in bytes of a single trace output file. This value should be in the range ``[0, INT64_MAX]``. If the value is set to 0, there is no limit on individual file size. The default is a maximum size of 10,485,760 bytes. +// +// Parameter: max size of a single trace output file +func (o NetworkOptions) SetTraceRollSize(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(31, b) +} + +// Sets the maximum size of all the trace output files put together. This value should be in the range ``[0, INT64_MAX]``. If the value is set to 0, there is no limit on the total size of the files. The default is a maximum size of 104,857,600 bytes. If the default roll size is used, this means that a maximum of 10 trace files will be written at a time. +// +// Parameter: max total size of trace files +func (o NetworkOptions) SetTraceMaxLogsSize(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(32, b) +} + +// Sets the 'logGroup' attribute with the specified value for all events in the trace output files. The default log group is 'default'. +// +// Parameter: value of the logGroup attribute +func (o NetworkOptions) SetTraceLogGroup(param string) error { + return o.setOpt(33, []byte(param)) +} + +// Set internal tuning or debugging knobs +// +// Parameter: knob_name=knob_value +func (o NetworkOptions) SetKnob(param string) error { + return o.setOpt(40, []byte(param)) +} + +// Set the TLS plugin to load. This option, if used, must be set before any other TLS options +// +// Parameter: file path or linker-resolved name +func (o NetworkOptions) SetTLSPlugin(param string) error { + return o.setOpt(41, []byte(param)) +} + +// Set the certificate chain +// +// Parameter: certificates +func (o NetworkOptions) SetTLSCertBytes(param []byte) error { + return o.setOpt(42, param) +} + +// Set the file from which to load the certificate chain +// +// Parameter: file path +func (o NetworkOptions) SetTLSCertPath(param string) error { + return o.setOpt(43, []byte(param)) +} + +// Set the private key corresponding to your own certificate +// +// Parameter: key +func (o NetworkOptions) SetTLSKeyBytes(param []byte) error { + return o.setOpt(45, param) +} + +// Set the file from which to load the private key corresponding to your own certificate +// +// Parameter: file path +func (o NetworkOptions) SetTLSKeyPath(param string) error { + return o.setOpt(46, []byte(param)) +} + +// Set the peer certificate field verification criteria +// +// Parameter: verification pattern +func (o NetworkOptions) SetTLSVerifyPeers(param []byte) error { + return o.setOpt(47, param) +} + +// Not yet implemented. +func (o NetworkOptions) SetBuggifyEnable() error { + return o.setOpt(48, nil) +} + +// Not yet implemented. +func (o NetworkOptions) SetBuggifyDisable() error { + return o.setOpt(49, nil) +} + +// Set the probability of a BUGGIFY section being active for the current execution. Only applies to code paths first traversed AFTER this option is changed. +// +// Parameter: probability expressed as a percentage between 0 and 100 +func (o NetworkOptions) SetBuggifySectionActivatedProbability(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(50, b) +} + +// Set the probability of an active BUGGIFY section being fired +// +// Parameter: probability expressed as a percentage between 0 and 100 +func (o NetworkOptions) SetBuggifySectionFiredProbability(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(51, b) +} + +// Disables the multi-version client API and instead uses the local client directly. Must be set before setting up the network. +func (o NetworkOptions) SetDisableMultiVersionClientApi() error { + return o.setOpt(60, nil) +} + +// If set, callbacks from external client libraries can be called from threads created by the FoundationDB client library. Otherwise, callbacks will be called from either the thread used to add the callback or the network thread. Setting this option can improve performance when connected using an external client, but may not be safe to use in all environments. Must be set before setting up the network. WARNING: This feature is considered experimental at this time. +func (o NetworkOptions) SetCallbacksOnExternalThreads() error { + return o.setOpt(61, nil) +} + +// Adds an external client library for use by the multi-version client API. Must be set before setting up the network. +// +// Parameter: path to client library +func (o NetworkOptions) SetExternalClientLibrary(param string) error { + return o.setOpt(62, []byte(param)) +} + +// Searches the specified path for dynamic libraries and adds them to the list of client libraries for use by the multi-version client API. Must be set before setting up the network. +// +// Parameter: path to directory containing client libraries +func (o NetworkOptions) SetExternalClientDirectory(param string) error { + return o.setOpt(63, []byte(param)) +} + +// Prevents connections through the local client, allowing only connections through externally loaded client libraries. Intended primarily for testing. +func (o NetworkOptions) SetDisableLocalClient() error { + return o.setOpt(64, nil) +} + +// Disables logging of client statistics, such as sampled transaction activity. +func (o NetworkOptions) SetDisableClientStatisticsLogging() error { + return o.setOpt(70, nil) +} + +// Enables debugging feature to perform slow task profiling. Requires trace logging to be enabled. WARNING: this feature is not recommended for use in production. +func (o NetworkOptions) SetEnableSlowTaskProfiling() error { + return o.setOpt(71, nil) +} + +// Set the size of the client location cache. Raising this value can boost performance in very large databases where clients access data in a near-random pattern. Defaults to 100000. +// +// Parameter: Max location cache entries +func (o DatabaseOptions) SetLocationCacheSize(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(10, b) +} + +// Set the maximum number of watches allowed to be outstanding on a database connection. Increasing this number could result in increased resource usage. Reducing this number will not cancel any outstanding watches. Defaults to 10000 and cannot be larger than 1000000. +// +// Parameter: Max outstanding watches +func (o DatabaseOptions) SetMaxWatches(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(20, b) +} + +// Specify the machine ID that was passed to fdbserver processes running on the same machine as this client, for better location-aware load balancing. +// +// Parameter: Hexadecimal ID +func (o DatabaseOptions) SetMachineId(param string) error { + return o.setOpt(21, []byte(param)) +} + +// Specify the datacenter ID that was passed to fdbserver processes running in the same datacenter as this client, for better location-aware load balancing. +// +// Parameter: Hexadecimal ID +func (o DatabaseOptions) SetDatacenterId(param string) error { + return o.setOpt(22, []byte(param)) +} + +// The transaction, if not self-conflicting, may be committed a second time after commit succeeds, in the event of a fault +func (o TransactionOptions) SetCausalWriteRisky() error { + return o.setOpt(10, nil) +} + +// The read version will be committed, and usually will be the latest committed, but might not be the latest committed in the event of a fault or partition +func (o TransactionOptions) SetCausalReadRisky() error { + return o.setOpt(20, nil) +} + +// Not yet implemented. +func (o TransactionOptions) SetCausalReadDisable() error { + return o.setOpt(21, nil) +} + +// The next write performed on this transaction will not generate a write conflict range. As a result, other transactions which read the key(s) being modified by the next write will not conflict with this transaction. Care needs to be taken when using this option on a transaction that is shared between multiple threads. When setting this option, write conflict ranges will be disabled on the next write operation, regardless of what thread it is on. +func (o TransactionOptions) SetNextWriteNoWriteConflictRange() error { + return o.setOpt(30, nil) +} + +// Committing this transaction will bypass the normal load balancing across proxies and go directly to the specifically nominated 'first proxy'. +func (o TransactionOptions) SetCommitOnFirstProxy() error { + return o.setOpt(40, nil) +} + +// Not yet implemented. +func (o TransactionOptions) SetCheckWritesEnable() error { + return o.setOpt(50, nil) +} + +// Reads performed by a transaction will not see any prior mutations that occured in that transaction, instead seeing the value which was in the database at the transaction's read version. This option may provide a small performance benefit for the client, but also disables a number of client-side optimizations which are beneficial for transactions which tend to read and write the same keys within a single transaction. +func (o TransactionOptions) SetReadYourWritesDisable() error { + return o.setOpt(51, nil) +} + +// Disables read-ahead caching for range reads. Under normal operation, a transaction will read extra rows from the database into cache if range reads are used to page through a series of data one row at a time (i.e. if a range read with a one row limit is followed by another one row range read starting immediately after the result of the first). +func (o TransactionOptions) SetReadAheadDisable() error { + return o.setOpt(52, nil) +} + +// Not yet implemented. +func (o TransactionOptions) SetDurabilityDatacenter() error { + return o.setOpt(110, nil) +} + +// Not yet implemented. +func (o TransactionOptions) SetDurabilityRisky() error { + return o.setOpt(120, nil) +} + +// Not yet implemented. +func (o TransactionOptions) SetDurabilityDevNullIsWebScale() error { + return o.setOpt(130, nil) +} + +// Specifies that this transaction should be treated as highest priority and that lower priority transactions should block behind this one. Use is discouraged outside of low-level tools +func (o TransactionOptions) SetPrioritySystemImmediate() error { + return o.setOpt(200, nil) +} + +// Specifies that this transaction should be treated as low priority and that default priority transactions should be processed first. Useful for doing batch work simultaneously with latency-sensitive work +func (o TransactionOptions) SetPriorityBatch() error { + return o.setOpt(201, nil) +} + +// This is a write-only transaction which sets the initial configuration. This option is designed for use by database system tools only. +func (o TransactionOptions) SetInitializeNewDatabase() error { + return o.setOpt(300, nil) +} + +// Allows this transaction to read and modify system keys (those that start with the byte 0xFF) +func (o TransactionOptions) SetAccessSystemKeys() error { + return o.setOpt(301, nil) +} + +// Allows this transaction to read system keys (those that start with the byte 0xFF) +func (o TransactionOptions) SetReadSystemKeys() error { + return o.setOpt(302, nil) +} + +// Not yet implemented. +func (o TransactionOptions) SetDebugDump() error { + return o.setOpt(400, nil) +} + +// Not yet implemented. +func (o TransactionOptions) SetDebugRetryLogging(param string) error { + return o.setOpt(401, []byte(param)) +} + +// Enables tracing for this transaction and logs results to the client trace logs. Client trace logging must be enabled to get log output. +// +// Parameter: String identifier to be used in the logs when tracing this transaction. The identifier must not exceed 100 characters. +func (o TransactionOptions) SetTransactionLoggingEnable(param string) error { + return o.setOpt(402, []byte(param)) +} + +// Set a timeout in milliseconds which, when elapsed, will cause the transaction automatically to be cancelled. Valid parameter values are ``[0, INT_MAX]``. If set to 0, will disable all timeouts. All pending and any future uses of the transaction will throw an exception. The transaction can be used again after it is reset. Like all transaction options, a timeout must be reset after a call to onError. This behavior allows the user to make the timeout dynamic. +// +// Parameter: value in milliseconds of timeout +func (o TransactionOptions) SetTimeout(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(500, b) +} + +// Set a maximum number of retries after which additional calls to onError will throw the most recently seen error code. Valid parameter values are ``[-1, INT_MAX]``. If set to -1, will disable the retry limit. Like all transaction options, the retry limit must be reset after a call to onError. This behavior allows the user to make the retry limit dynamic. +// +// Parameter: number of times to retry +func (o TransactionOptions) SetRetryLimit(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(501, b) +} + +// Set the maximum amount of backoff delay incurred in the call to onError if the error is retryable. Defaults to 1000 ms. Valid parameter values are ``[0, INT_MAX]``. Like all transaction options, the maximum retry delay must be reset after a call to onError. If the maximum retry delay is less than the current retry delay of the transaction, then the current retry delay will be clamped to the maximum retry delay. +// +// Parameter: value in milliseconds of maximum delay +func (o TransactionOptions) SetMaxRetryDelay(param int64) error { + b, e := int64ToBytes(param) + if e != nil { + return e + } + return o.setOpt(502, b) +} + +// Snapshot read operations will see the results of writes done in the same transaction. +func (o TransactionOptions) SetSnapshotRywEnable() error { + return o.setOpt(600, nil) +} + +// Snapshot read operations will not see the results of writes done in the same transaction. +func (o TransactionOptions) SetSnapshotRywDisable() error { + return o.setOpt(601, nil) +} + +// The transaction can read and write to locked databases, and is resposible for checking that it took the lock. +func (o TransactionOptions) SetLockAware() error { + return o.setOpt(700, nil) +} + +// By default, operations that are performed on a transaction while it is being committed will not only fail themselves, but they will attempt to fail other in-flight operations (such as the commit) as well. This behavior is intended to help developers discover situations where operations could be unintentionally executed after the transaction has been reset. Setting this option removes that protection, causing only the offending operation to fail. +func (o TransactionOptions) SetUsedDuringCommitProtectionDisable() error { + return o.setOpt(701, nil) +} + +// The transaction can read from locked databases. +func (o TransactionOptions) SetReadLockAware() error { + return o.setOpt(702, nil) +} + +type StreamingMode int + +const ( + + // Client intends to consume the entire range and would like it all + // transferred as early as possible. + StreamingModeWantAll StreamingMode = -1 + + // The default. The client doesn't know how much of the range it is likely + // to used and wants different performance concerns to be balanced. Only a + // small portion of data is transferred to the client initially (in order to + // minimize costs if the client doesn't read the entire range), and as the + // caller iterates over more items in the range larger batches will be + // transferred in order to minimize latency. + StreamingModeIterator StreamingMode = 0 + + // Infrequently used. The client has passed a specific row limit and wants + // that many rows delivered in a single batch. Because of iterator operation + // in client drivers make request batches transparent to the user, consider + // ``WANT_ALL`` StreamingMode instead. A row limit must be specified if this + // mode is used. + StreamingModeExact StreamingMode = 1 + + // Infrequently used. Transfer data in batches small enough to not be much + // more expensive than reading individual rows, to minimize cost if + // iteration stops early. + StreamingModeSmall StreamingMode = 2 + + // Infrequently used. Transfer data in batches sized in between small and + // large. + StreamingModeMedium StreamingMode = 3 + + // Infrequently used. Transfer data in batches large enough to be, in a + // high-concurrency environment, nearly as efficient as possible. If the + // client stops iteration early, some disk and network bandwidth may be + // wasted. The batch size may still be too small to allow a single client to + // get high throughput from the database, so if that is what you need + // consider the SERIAL StreamingMode. + StreamingModeLarge StreamingMode = 4 + + // Transfer data in batches large enough that an individual client can get + // reasonable read bandwidth from the database. If the client stops + // iteration early, considerable disk and network bandwidth may be wasted. + StreamingModeSerial StreamingMode = 5 +) + +// Add performs an addition of little-endian integers. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The integers to be added must be stored in a little-endian representation. They can be signed in two's complement representation or unsigned. You can add to an integer at a known offset in the value by prepending the appropriate number of zero bytes to ``param`` and padding with zero bytes to match the length of the value. However, this offset technique requires that you know the addition will not cause the integer field within the value to overflow. +func (t Transaction) Add(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 2) +} + +// BitAnd performs a bitwise ``and`` operation. If the existing value in the database is not present, then ``param`` is stored in the database. If the existing value in the database is shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. +func (t Transaction) BitAnd(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 6) +} + +// BitOr performs a bitwise ``or`` operation. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. +func (t Transaction) BitOr(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 7) +} + +// BitXor performs a bitwise ``xor`` operation. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. +func (t Transaction) BitXor(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 8) +} + +// Max performs a little-endian comparison of byte strings. If the existing value in the database is not present or shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The larger of the two values is then stored in the database. +func (t Transaction) Max(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 12) +} + +// Min performs a little-endian comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored in the database. If the existing value in the database is shorter than ``param``, it is first extended to the length of ``param`` with zero bytes. If ``param`` is shorter than the existing value in the database, the existing value is truncated to match the length of ``param``. The smaller of the two values is then stored in the database. +func (t Transaction) Min(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 13) +} + +// SetVersionstampedKey transforms ``key`` using a versionstamp for the transaction. Sets the transformed key in the database to ``param``. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database. The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time versionstamps are compatible with the Tuple layer only in the Java and Python bindings. Note that this implies versionstamped keys may not be used with the Subspace and Directory layers except in those languages. +func (t Transaction) SetVersionstampedKey(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 14) +} + +// SetVersionstampedValue transforms ``param`` using a versionstamp for the transaction. Sets ``key`` in the database to the transformed parameter. A versionstamp is a 10 byte, unique, monotonically (but not sequentially) increasing value for each committed transaction. The first 8 bytes are the committed version of the database. The last 2 bytes are monotonic in the serialization order for transactions. WARNING: At this time versionstamped values are not compatible with the Tuple layer. +func (t Transaction) SetVersionstampedValue(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 15) +} + +// ByteMin performs lexicographic comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored. Otherwise the smaller of the two values is then stored in the database. +func (t Transaction) ByteMin(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 16) +} + +// ByteMax performs lexicographic comparison of byte strings. If the existing value in the database is not present, then ``param`` is stored. Otherwise the larger of the two values is then stored in the database. +func (t Transaction) ByteMax(key KeyConvertible, param []byte) { + t.atomicOp(key.FDBKey(), param, 17) +} + +type conflictRangeType int + +const ( + + // Used to add a read conflict range + conflictRangeTypeRead conflictRangeType = 0 + + // Used to add a write conflict range + conflictRangeTypeWrite conflictRangeType = 1 +) + +type ErrorPredicate int + +const ( + + // Returns ``true`` if the error indicates the operations in the + // transactions should be retried because of transient error. + ErrorPredicateRetryable ErrorPredicate = 50000 + + // Returns ``true`` if the error indicates the transaction may have + // succeeded, though not in a way the system can verify. + ErrorPredicateMaybeCommitted ErrorPredicate = 50001 + + // Returns ``true`` if the error indicates the transaction has not + // committed, though in a way that can be retried. + ErrorPredicateRetryableNotCommitted ErrorPredicate = 50002 +) diff --git a/documentation/Makefile b/documentation/Makefile index c5ae0870e1e..256b2b7bd5f 100644 --- a/documentation/Makefile +++ b/documentation/Makefile @@ -3,7 +3,6 @@ include ../build/scver.mk docprereqs: $(MAKE) -C sphinx html cp -r ../bindings/java/javadoc sphinx/.out/html - cp -r ../bindings/go/godoc sphinx/.out/html rm -f sphinx/.out/html/documentation ln -s . sphinx/.out/html/documentation diff --git a/documentation/sphinx/source/api-reference.rst b/documentation/sphinx/source/api-reference.rst index 4527d2a6a8a..1b3c69857cd 100644 --- a/documentation/sphinx/source/api-reference.rst +++ b/documentation/sphinx/source/api-reference.rst @@ -13,6 +13,6 @@ The following documents give detailed descriptions of the API for each language: api-python api-ruby Java API - Go API + Go API api-c api-error-codes diff --git a/fdbclient/vexillographer/fdb.options b/fdbclient/vexillographer/fdb.options index 17a5af781b9..9f283337ac2 100644 --- a/fdbclient/vexillographer/fdb.options +++ b/fdbclient/vexillographer/fdb.options @@ -82,7 +82,7 @@ description is not currently required but encouraged.