package
23.1.1+incompatible
Repository: https://github.com/dgraph-io/dgraph.git
Documentation: pkg.go.dev

# Functions

AddCorsHeaders adds the CORS headers to an HTTP response.
AskUserPassword prompts the user to enter the password for the given user ID.
AssertTrue asserts that b is true.
AssertTruef is AssertTrue with extra info.
AssertTruefNoTrace is AssertTruef without a stack trace.
AttachAccessJwt adds any incoming JWT header data into the grpc context metadata.
AttachAuthToken adds any incoming PoorMan's auth header data into the grpc context metadata.
AttachGalaxyOperation specifies in the context that it will be used for doing a galaxy operation.
AttachJWTNamespace attaches the namespace in the JWT claims to the context if present, otherwise it attaches the galaxy namespace.
AttachJWTNamespaceOutgoing attaches the namespace in the JWT claims to the outgoing metadata of the context.
AttachNamespace adds given namespace to the metadata of the context.
AttachNamespaceOutgoing adds given namespace in the outgoing metadata of the context.
AttachRemoteIP adds any incoming IP data into the grpc context metadata.
AttrFrom2103 parses namespace that were stored in format used before 21.03 version.
BuildDetails returns a string containing details about the Dgraph binary.
CaptureSentryException sends the error report to Sentry.
Check logs fatal if err != nil.
Check2 acts as convenience wrapper around Check, using the 2nd argument as error.
Checkf is Check with extra info.
CheckfNoLog exits on error without any message (to avoid duplicate error messages).
CheckfNoTrace is Checkf without a stack trace.
ConfigureSentryScope configures the scope on the global hub of Sentry.
CountKey generates a count key with the given attribute and uid.
DataKey generates a data key with the given attribute and UID.
DataPrefix returns the prefix for all data keys belonging to this namespace.
DeepCopyJsonArray returns a deep copy of the input array `a`.
DeepCopyJsonMap returns a deep copy of the input map `m`.
DevVersion returns true if the version string contains the above pattern e.g.
Diff computes the difference between the keys of the two given maps.
DivideAndRule is used to divide a number of tasks among multiple go routines.
ExecutableChecksum returns a byte slice containing the SHA256 checksum of the executable.
ExponentialRetry runs the given function until it succeeds or can no longer be retried.
ExtractNamespace parses the namespace value from the incoming gRPC context.
ExtractNamespaceHTTP parses the namespace value from the incoming HTTP request.
Fatalf logs fatal.
FillCommonFlags stores flags common to Alpha and Zero.
FindDataFiles returns a list of data files as a string array.
FindFilesFunc walks the directory 'dir' and collects all file names matched by func f.
FixedDuration returns the given duration as a string of fixed length.
FlushSentry flushes the buffered events/errors.
FromBackupKey takes a key in the format used for backups and converts it to a key.
GenerateClientTLSConfig creates and returns a new client side *tls.Config with the configuration provided.
GenerateServerTLSConfig creates and returns a new *tls.Config with the configuration provided.
GetCachePercentages returns the slice of cache percentages given the "," (comma) separated cache percentages(integers) string and expected number of caches.
GetDgraphClient creates a Dgraph client based on the following options in the configuration: --slash_grpc_endpoint specifies the grpc endpoint for slash.
GetPassAndLogin uses the given credentials and client to perform the login operation.
GetRandomName generates a random name from the list of adjectives and surnames in this package formatted as "adjective_surname".
GqlErrorf returns a new GqlError with the message and args Sprintf'ed as the GqlError's Message.
HasString returns whether the slice contains the given string.
HasWhitelistedIP checks whether the source IP in ctx is whitelisted or not.
HealthCheck returns whether the server is ready to accept requests or not Load balancer would add the node to the endpoint once health check starts returning true.
Ignore function is used to ignore errors deliberately, while keeping the linter happy.
IndexKey generates a index key with the given attribute and term.
InitSentry initializes the sentry machinery.
IsAclPredicate returns true if the predicate is in the list of reserved predicates for the ACL feature.
IsGqlErrorList tells whether the given err is a list of GraphQL errors.
IsGraphqlReservedPredicate returns true if it is the predicate is reserved by graphql.
IsInternalPredicate returns true if the predicate is in the internal predicate list.
IsJwtExpired returns true if the error indicates that the jwt has expired.
IsMissingOrEmptyDir returns true if the path either does not exist or is a directory that is empty.
IsPreDefinedPredicate returns true only if the predicate has been defined by dgraph internally in the initial schema.
IsPreDefinedType returns true only if the typ has been defined by dgraph internally.
IsReservedPredicate returns true if the predicate is reserved for internal usage, i.e., prefixed with `dgraph.`.
IsReservedType returns true if the given typ is reserved for internal usage, i.e., prefixed with `dgraph.`.
KvWithMaxVersion returns a KV with the max version from the list of KVs.
LambdaUrl returns the correct lambda-url for the given namespace.
LoadClientTLSConfig loads the TLS config into the client with the given parameters.
LoadClientTLSConfigForInternalPort loads tls config for connecting to internal ports of cluster.
LoadServerTLSConfig loads the TLS config into the server with the given parameters.
LoadServerTLSConfigForInternalPort loads the TLS config for the internal ports of the cluster.
Max returns the maximum of the two given numbers.
MetricsContext returns a context with tags that are useful for distinguishing the state of the running system.
Min returns the minimum of the two given numbers.
MonitorCacheHealth periodically monitors the cache metrics and reports if there is high contention in the cache.
NamespaceAttr is used to generate attr from namespace.
NewBadgerCollector returns a prometheus Collector for Badger metrics from expvar.
NewHistogram initializes a given Histogram.
NewRateLimiter creates a rate limiter that limits lease by maxTokens in an interval specified by refillAfter.
PageRange returns start and end indices given pagination params.
Panic on error.
PanicHandler is the callback function when a panic happens.
Parse would parse the key.
ParseAttr returns the attr from the given value.
ParseCompression returns badger.compressionType and compression level given compression string of format compression-type:compression-level.
ParseNamespace returns the namespace from the given value.
ParseNamespaceAttr returns the namespace and attr from the given value.
ParseRequest parses the body of the given request.
PredicateLang extracts the language from a predicate (or facet) name.
PredicatePrefix returns the prefix for all keys belonging to this predicate except schema key.
PrefixesToMatches converts the prefixes for subscription to a list of match.
PrintMutationEdge prints all edges that are being inserted into badger.
PrintOracleDelta prints all delta proposals that are commited.
PrintRollup prints information about any rollup that happen.
PrintVersion prints version and other helpful information if --version.
{2 bytes Node ID} {4 bytes for random} {2 bytes zero}.
ReadGroupIdFile reads the file at the given path and attempts to retrieve the group ID stored in it.
ReadLine reads a single line from a buffered reader.
RegisterClientTLSFlags registers the required flags to set up a TLS client.
RegisterExporters sets up the services to which metrics will be exported.
RegisterServerTLSFlags registers the required flags to set up a TLS server.
RemoveCidFile removes the file.
RemoveDuplicates sorts the slice of strings and removes duplicates.
Reply sets the body of an HTTP response to the JSON representation of the given reply.
RetryUntilSuccess runs the given function until it succeeds or can no longer be retried.
ReverseKey generates a reverse key with the given attribute and UID.
RunVlogGC runs value log gc on store.
SchemaKey returns schema key for given attribute.
SchemaPrefix returns the prefix for Schema keys.
SentryOptOutNote - This is an opt out banner.
SetHttpStatus is similar to SetStatus but sets a proper HTTP status code in the response instead of always returning HTTP 200 (OK).
SetStatus sets the error code, message and the newly assigned uids in the http response.
SetStatusWithData sets the errors in the response and ensures that the data key in the data is present with value nil.
SetupConnection starts a secure gRPC connection to the given host.
ShouldCrash returns true if the error should cause the process to crash.
SinceMs returns the time since startTime in milliseconds (as a float).
SlashTLSConfig returns the TLS config appropriate for SlashGraphQL This assumes that endpoint is not empty, and in the format "domain.grpc.cloud.dg.io:443".
SpanTimer returns a function used to record the duration of the given span.
SplitKey takes a key baseKey and generates the key of the list split that starts at startUid.
StarAllPredicates returns the complete list of pre-defined predicates that needs to be expanded when * is given as a predicate.
StartProfile starts a new mode for profiling.
TLSBaseConfig returns a *tls.Config with the base set of security requirements (minimum TLS v1.2 and set of cipher suites).
ToHex converts a uint64 to a hex byte array.
TypeKey returns type key for given type name.
TypePrefix returns the prefix for Schema keys.
Unique takes an array and returns it with no duplicate entries.
UpdateDrainingMode updates the server's draining mode.
UpdateHealthStatus updates the server's health status so it can start accepting requests.
ValidateAddress checks whether given address can be used with grpc dial function.
ValueType s a helper function to decide value type of DirectedEdge/Posting/N-Quad.
VerifyPack works in debug mode.
VerifyPostingSplits works in debug mode.
VerifySnapshot works in debug mode.
Version returns a string containing the dgraphVersion.
WalkPathFunc walks the directory 'dir' and collects all path names matched by func f.
WithAuthorizationCredentials adds Authorization: <api-token> to every GRPC request This is mostly used by Slash GraphQL to authenticate requests.
WithMethod returns a new updated context with the tag KeyMethod set to the given value.
WrapPanics is a wrapper on panics.
WriteCidFile writes the CID to a well-known location so it can be read and sent to Sentry on panic.
WriteFileSync is the same as bufio.WriteFile, but syncs the data before closing.
WriteGroupIdFile writes the given group ID to the group_id file inside the given postings directory.
WriteResponse writes response body, transparently compressing if necessary.

# Constants

ByteCount indicates the key stores a count index.
ByteCountRev indicates the key stores a reverse count index.
ByteData indicates the key stores data.
ByteIndex indicates the key stores an index.
ByteReverse indicates the key stores a reverse index.
ByteSplit signals that the key stores an individual part of a multi-part list.
ByteUnused is a constant to specify keys which need to be discarded.
DefaultCreds is the default credentials for login via dgo client.
DefaultPrefix is the prefix used for data, index and reverse keys so that relative order of data doesn't change keys of same attributes are located together.
Error is a general error code.
ErrorInvalidMethod is equivalent to the HTTP 405 error code.
ErrorInvalidRequest is equivalent to the HTTP 400 error code.
ErrorNoData is an error returned when the requested data cannot be returned.
ErrorUnauthorized is equivalent to the HTTP 401 error code.
FacetDelimiter is the symbol used to distinguish predicate names from facets.
ForceAbortDifference is the maximum allowed difference between AppliedUntil - TxnMarks.DoneUntil() before old transactions start getting aborted.
GalaxyNamespace is the default namespace name.
GrootId is the ID of the admin user for ACLs.
GroupIdFileName is the name of the file storing the ID of the group to which the data in a postings directory belongs.
GrpcMaxSize is the maximum possible size for a gRPC message.
GuardiansId is the ID of the admin group for ACLs.
IgnoreBytes is the byte range which will be ignored while prefix match in subscription.
NamespaceOffset is the offset in badger key from which the next 8 bytes contain namespace.
NsSeparator is the separator between the namespace and attribute.
PortGrpc is the default gRPC port for alpha.
PortHTTP is the default HTTP port for alpha.
PortInternal is the default port for internal use.
PortZeroGrpc is the default gRPC port for zero.
PortZeroHTTP is the default HTTP port for zero.
Star is equivalent to using * in a mutation.
Success is equivalent to the HTTP 200 error code.
ValidHostnameRegex is a regex that accepts our expected hostname format.
ValueEmpty represents a value with no UID and no value.
ValueMulti represents a value which is part of a multi-value posting list (like language).
ValuePlain represents a plain old value without defined language tag.
ValueUid represents a value with an UID.
ValueUnknown represents an unknown type of value.
old logs before https://github.com/dgraph-io/dgraph/pull/8323 contain deprecated verification text in header.

# Variables

ActiveMutations is the current number of active mutations.
AlphaHealth status records the current health of the alphas.
Conf holds the metrics config.
Config stores the global instance of this package's options.
DiskFree records the number of bytes free on the disk.
DiskTotal records the number of bytes free on the disk.
DiskUsed records the number of bytes free on the disk.
ErrConflict is returned when commit couldn't succeed due to conflicts.
ErrHashMismatch is returned when the hash does not matches the startTs.
ErrMissingDir is thrown by IsMissingOrEmptyDir if the given path is a missing or empty directory.
ErrNoJwt is returned when JWT is not present in the context.
ErrNotSupported is thrown when an enterprise feature is requested in the open source version.
ErrorInvalidLogin is returned when username or password is incorrect in login.
GrootUid is a map from namespace to the Uid of groot user node.
GuardiansUid is a map from namespace to the Uid of guardians group node.
KeyDirType is the tag key used to record the group for FileSystem metrics.
KeyGroup is the tag key used to record the group for Raft metrics.
KeyMethod is the tag key used to record the method (e.g read or mutate).
KeyStatus is the tag key used to record the status of the server.
LatencyMs is the latency of the various Dgraph operations.
MaxAssignedTs records the latest max assigned timestamp.
MemoryAlloc records the amount of memory allocated via jemalloc.
MemoryIdle records the amount of memory held by the runtime but not in-use by Dgraph.
MemoryInUse records the current amount of used memory by Dgraph.
MemoryProc records the amount of memory used in processes.
Nilbyte is a nil byte slice.
NonRootTemplate defines the help template for dgraph sub-command.
NumBackups is the number of backups requested.
NumBackupsFailed is the number of backups failed.
NumBackupsSuccess is the number of backups successfully completed.
NumEdges is the total number of edges created so far.
NumMutations is the total number of mutations processed so far.
NumQueries is the total number of queries processed so far.
PBlockHitRatio records the hit ratio of posting store block cache.
PendingBackups records if a backup is currently in progress.
PendingProposals records the current number of pending RAFT proposals.
PendingQueries records the current number of pending queries.
PIndexHitRatio records the hit ratio of posting store index cache.
PLCacheHitRatio records the hit ratio of posting list cache.
RaftAppliedIndex records the latest applied RAFT index.
RaftHasLeader records whether this instance has a leader.
RaftIsLeader records whether this instance is the leader.
RaftLeaderChanges records the total number of leader changes seen.
RootTemplate defines the help template for dgraph command.
ServerCloser is used to signal and wait for other goroutines to return gracefully after user requests shutdown.
TagValueStatusError is the tag value used to signal an unsuccessful operation.
TagValueStatusOK is the tag value used to signal a successful operation.
TxnAborts records count of aborted transactions by the server.
TxnCommits records count of committed transactions.
TxnDiscards records count of discarded transactions by the client.
WhiteSpace Replacer removes spaces and tabs from a string.
WorkerConfig stores the global instance of the worker package's options.

# Structs

BytesBuffer provides a buffer backed by byte slices.
CredOpt stores the options for logging in, including the password and user.
GqlError is a GraphQL spec compliant error structure.
A Histogram collects observed values by keeping bucketed counts.
IPRange represents an IP range.
LimiterConf is the configuration options for LimiterConf.
A Location is the Line+Column index of an error in a request.
MinioCredentials holds the credentials needed to perform a backup/export operation.
Options stores the options for this package.
ParsedKey represents a key that has been parsed into its multiple attributes.
QueryResWithData represents a response that holds errors as well as data.
RateLimiter implements a basic rate limiter.
SafeMutex can be used in place of sync.RWMutex.
SubCommand a represents a sub-command in the command-line interface.
Timer implements a timer that supports recording the duration of events.
TLSHelperConfig define params used to create a tls.Config.
ToGlog is a logger that forwards the output to glog.
WorkerOptions stores the options for the worker package.

# Interfaces

Stopper is an interface tasked with stopping the profiling process.

# Type aliases

CloseFunc needs to be called to close all the client connections.
GqlErrorList is a list of GraphQL errors as would be found in a response.
Sensitive implements the Stringer interface to redact its contents.
ValueTypeInfo represents information about the type of values in DirectedEdge/Posting/N-Quad.