Documentation ¶
Index ¶
- Variables
- func Expand(ctx context.Context, key MessageKey, inserts ...interface{}) string
- func ExpandWithCode(ctx context.Context, key MessageKey, inserts ...interface{}) string
- func GetFieldType(code string) (string, bool)
- func GetStatusHint(code string) (int, bool)
- func NewError(ctx context.Context, msg ErrorMessageKey, inserts ...interface{}) error
- func SetLang(lang string)
- func WithLang(ctx context.Context, lang language.Tag) context.Context
- func WrapError(ctx context.Context, err error, msg ErrorMessageKey, inserts ...interface{}) error
- type ConfigMessageKey
- type ErrorMessageKey
- type MessageKey
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ConfigGlobalConnectionTimeout = ffc("config.global.connectionTimeout", "The maximum amount of time that a connection is allowed to remain with no data transmitted", TimeDurationType) ConfigGlobalRequestTimeout = ffc("config.global.requestTimeout", "The maximum amount of time that a request is allowed to remain open", TimeDurationType) ConfigGlobalRetryEnabled = ffc("config.global.retry.enabled", "Enables retries", BooleanType) ConfigGlobalRetryFactor = ffc("config.global.retry.factor", "The retry backoff factor", FloatType) ConfigGlobalRetryInitDelay = ffc("config.global.retry.initDelay", "The initial retry delay", TimeDurationType) ConfigGlobalRetryInitialDelay = ffc("config.global.retry.initialDelay", "The initial retry delay", TimeDurationType) ConfigGlobalRetryMaxDelay = ffc("config.global.retry.maxDelay", "The maximum retry delay", TimeDurationType) ConfigGlobalRetryMaxAttempts = ffc("config.global.retry.maxAttempts", "The maximum number attempts", IntType) ConfigGlobalRetryCount = ffc("config.global.retry.count", "The maximum number of times to retry", IntType) ConfigGlobalInitWaitTime = ffc("config.global.retry.initWaitTime", "The initial retry delay", TimeDurationType) ConfigGlobalMaxWaitTime = ffc("config.global.retry.maxWaitTime", "The maximum retry delay", TimeDurationType) ConfigGlobalUsername = ffc("config.global.auth.username", "Username", StringType) ConfigGlobalPassword = ffc("config.global.auth.password", "Password", StringType) ConfigGlobalProxyURL = ffc("config.global.proxy.url", "Optional HTTP proxy server to connect through", StringType) ConfigGlobalSize = ffc("config.global.cache.size", "The size of the cache", ByteSizeType) ConfigGlobalTTL = ffc("config.global.cache.ttl", "The time to live (TTL) for the cache", TimeDurationType) ConfigGlobalWsHeartbeatInterval = ffc("config.global.ws.heartbeatInterval", "The amount of time to wait between heartbeat signals on the WebSocket connection", TimeDurationType) ConfigGlobalWsInitialConnectAttempts = ffc("config.global.ws.initialConnectAttempts", "The number of attempts FireFly will make to connect to the WebSocket when starting up, before failing", IntType) ConfigGlobalWsPath = ffc("config.global.ws.path", "The WebSocket sever URL to which FireFly should connect", "WebSocket URL "+StringType) ConfigGlobalWsReadBufferSize = ffc("config.global.ws.readBufferSize", "The size in bytes of the read buffer for the WebSocket connection", ByteSizeType) ConfigGlobalWsWriteBufferSize = ffc("config.global.ws.writeBufferSize", "The size in bytes of the write buffer for the WebSocket connection", ByteSizeType) ConfigGlobalTLSCaFile = ffc("config.global.tls.caFile", "The path to the CA file for TLS on this API", StringType) ConfigGlobalTLSCertFile = ffc("config.global.tls.certFile", "The path to the certificate file for TLS on this API", StringType) ConfigGlobalTLSClientAuth = ffc("config.global.tls.clientAuth", "Enables or disables client auth for TLS on this API", StringType) ConfigGlobalTLSEnabled = ffc("config.global.tls.enabled", "Enables or disables TLS on this API", BooleanType) ConfigGlobalTLSKeyFile = ffc("config.global.tls.keyFile", "The path to the private key file for TLS on this API", StringType) ConfigGlobalTLSHandshakeTimeout = ffc("config.global.tlsHandshakeTimeout", "The maximum amount of time to wait for a successful TLS handshake", TimeDurationType) ConfigGlobalBodyTemplate = ffc("config.global.bodyTemplate", "The body go template string to use when making HTTP requests", GoTemplateType) ConfigGlobalCustomClient = ffc("config.global.customClient", "Used for testing purposes only", IgnoredType) ConfigGlobalExpectContinueTimeout = ffc("config.global.expectContinueTimeout", "See [ExpectContinueTimeout in the Go docs](https://pkg.go.dev/net/http#Transport)", TimeDurationType) ConfigGlobalHeaders = ffc("config.global.headers", "Adds custom headers to HTTP requests", MapStringStringType) ConfigGlobalIdleTimeout = ffc("config.global.idleTimeout", "The max duration to hold a HTTP keepalive connection between calls", TimeDurationType) ConfigGlobalMaxIdleConns = ffc("config.global.maxIdleConns", "The max number of idle connections to hold pooled", IntType) ConfigGlobalMethod = ffc("config.global.method", "The HTTP method to use when making requests to the Address Resolver", StringType) ConfigGlobalAuthType = ffc("config.global.auth.type", "The auth plugin to use for server side authentication of requests", StringType) ConfigLang = ffc("config.lang", "Default language for translation (API calls may support language override using headers)", StringType) ConfigLogCompress = ffc("config.log.compress", "Determines if the rotated log files should be compressed using gzip", BooleanType) ConfigLogFilename = ffc("config.log.filename", "Filename is the file to write logs to. Backup log files will be retained in the same directory", StringType) ConfigLogFilesize = ffc("config.log.filesize", "MaxSize is the maximum size the log file before it gets rotated", ByteSizeType) ConfigLogForceColor = ffc("config.log.forceColor", "Force color to be enabled, even when a non-TTY output is detected", BooleanType) ConfigLogLevel = ffc("config.log.level", "The log level - error, warn, info, debug, trace", StringType) ConfigLogMaxAge = ffc("config.log.maxAge", "The maximum time to retain old log files based on the timestamp encoded in their filename.", TimeDurationType) ConfigLogMaxBackups = ffc("config.log.maxBackups", "Maximum number of old log files to retain", IntType) ConfigLogNoColor = ffc("config.log.noColor", "Force color to be disabled, event when TTY output is detected", BooleanType) ConfigLogTimeFormat = ffc("config.log.timeFormat", "Custom time format for logs", TimeFormatType) ConfigLogUtc = ffc("config.log.utc", "Use UTC timestamps for logs", BooleanType) ConfigLogIncludeCodeInfo = ffc("config.log.includeCodeInfo", "Enables the report caller for including the calling file and line number, and the calling function. If using text logs, it uses the logrus text format rather than the default prefix format.", BooleanType) ConfigLogJSONEnabled = ffc("config.log.json.enabled", "Enables JSON formatted logs rather than text. All log color settings are ignored when enabled.", BooleanType) ConfigLogJSONTimestampField = ffc("config.log.json.fields.timestamp", "Configures the JSON key containing the timestamp of the log", StringType) ConfigLogJSONLevelField = ffc("config.log.json.fields.level", "Configures the JSON key containing the log level", StringType) ConfigLogJSONMessageField = ffc("config.log.json.fields.message", "Configures the JSON key containing the log message", StringType) ConfigLogJSONFuncField = ffc("config.log.json.fields.func", "Configures the JSON key containing the calling function", StringType) ConfigLogJSONFileField = ffc("config.log.json.fields.file", "configures the JSON key containing the calling file", StringType) ConfigCorsCredentials = ffc("config.cors.credentials", "CORS setting to control whether a browser allows credentials to be sent to this API", BooleanType) ConfigCorsDebug = ffc("config.global.cors.debug", "Whether debug is enabled for the CORS implementation", BooleanType) ConfigCorsEnabled = ffc("config.global.cors.enabled", "Whether CORS is enabled", BooleanType) ConfigCorsHeaders = ffc("config.global.cors.headers", "CORS setting to control the allowed headers", ArrayStringType) ConfigCorsMaxAge = ffc("config.global.cors.maxAge", "The maximum age a browser should rely on CORS checks", TimeDurationType) ConfigCorsMethods = ffc("config.global.cors.methods", " CORS setting to control the allowed methods", ArrayStringType) ConfigCorsOrigins = ffc("config.global.cors.origins", "CORS setting to control the allowed origins", ArrayStringType) ConfigGlobalAuthBasicPasswordFile = ffc("config.global.basic.passwordfile", "The path to a .htpasswd file to use for authenticating requests. Passwords should be hashed with bcrypt.", StringType) )
View Source
var ( MsgConfigFailed = ffe("FF00101", "Failed to read config", 500) MsgBigIntTooLarge = ffe("FF00103", "Byte length of serialized integer is too large %d (max=%d)") MsgBigIntParseFailed = ffe("FF00104", "Failed to parse JSON value '%s' into BigInt") MsgTypeRestoreFailed = ffe("FF00105", "Failed to restore type '%T' into '%T'") MsgInvalidHex = ffe("FF00106", "Invalid hex supplied", 400) MsgInvalidWrongLenB32 = ffe("FF00107", "Byte length must be 32 (64 hex characters)", 400) MsgUnknownValidatorType = ffe("FF00108", "Unknown validator type: '%s'", 400) MsgDataValueIsNull = ffe("FF00109", "Data value is null", 400) MsgBlobMismatchSealingData = ffe("FF00110", "Blob mismatch when sealing data") MsgUnknownFieldValue = ffe("FF00111", "Unknown %s '%v'", 400) MsgMissingRequiredField = ffe("FF00112", "Field '%s' is required", 400) MsgDataInvalidHash = ffe("FF00113", "Invalid data: hashes do not match Hash=%s Expected=%s", 400) MsgNilID = ffe("FF00114", "ID is nil") MsgGroupMustHaveMembers = ffe("FF00115", "Group must have at least one member", 400) MsgEmptyMemberIdentity = ffe("FF00116", "Identity is blank in member %d") MsgEmptyMemberNode = ffe("FF00117", "Node is blank in member %d") MsgDuplicateMember = ffe("FF00118", "Member %d is a duplicate org+node combination: %s", 400) MsgGroupInvalidHash = ffe("FF00119", "Invalid group: hashes do not match Hash=%s Expected=%s", 400) MsgInvalidDIDForType = ffe("FF00120", "Invalid FireFly DID '%s' for type='%s' namespace='%s' name='%s'", 400) MsgCustomIdentitySystemNS = ffe("FF00121", "Custom identities cannot be defined in the '%s' namespace", 400) MsgSystemIdentityCustomNS = ffe("FF00122", "System identities must be defined in the '%s' namespace", 400) MsgNilParentIdentity = ffe("FF00124", "Identity of type '%s' must have a valid parent", 400) MsgNilOrNullObject = ffe("FF00125", "Object is null") MsgUnknownIdentityType = ffe("FF00126", "Unknown identity type: %s", 400) MsgJSONObjectParseFailed = ffe("FF00127", "Failed to parse '%s' as JSON") MsgNilDataReferenceSealFail = ffe("FF00128", "Invalid message: nil data reference at index %d", 400) MsgDupDataReferenceSealFail = ffe("FF00129", "Invalid message: duplicate data reference at index %d", 400) MsgInvalidTXTypeForMessage = ffe("FF00130", "Invalid transaction type for sending a message: %s", 400) MsgVerifyFailedNilHashes = ffe("FF00131", "Invalid message: nil hashes", 400) MsgVerifyFailedInvalidHashes = ffe("FF00132", "Invalid message: hashes do not match Hash=%s Expected=%s DataHash=%s DataHashExpected=%s", 400) MsgDuplicateArrayEntry = ffe("FF00133", "Duplicate %s at index %d: '%s'", 400) MsgTooManyItems = ffe("FF00134", "Maximum number of %s items is %d (supplied=%d)", 400) MsgFieldTooLong = ffe("FF00135", "Field '%s' maximum length is %d", 400) MsgTimeParseFail = ffe("FF00136", "Cannot parse time as RFC3339, Unix, or UnixNano: '%s'", 400) MsgDurationParseFail = ffe("FF00137", "Unable to parse '%s' as duration string, or millisecond number", 400) MsgInvalidUUID = ffe("FF00138", "Invalid UUID supplied", 400) MsgSafeCharsOnly = ffe("FF00139", "Field '%s' must include only alphanumerics (a-zA-Z0-9), dot (.), dash (-) and underscore (_)", 400) MsgInvalidName = ffe("FF00140", "Field '%s' must be 1-64 characters, including alphanumerics (a-zA-Z0-9), dot (.), dash (-) and underscore (_), and must start/end in an alphanumeric", 400) MsgNoUUID = ffe("FF00141", "Field '%s' must not be a UUID", 400) MsgInvalidFilterField = ffe("FF00142", "Unknown filter '%s'", 400) MsgInvalidValueForFilterField = ffe("FF00143", "Unable to parse value for filter '%s'", 400) MsgFieldMatchNoNull = ffe("FF00144", "Comparison operator for field '%s' cannot accept a null value", 400) MsgFieldTypeNoStringMatching = ffe("FF00145", "Field '%s' of type '%s' does not support partial or case-insensitive string matching", 400) MsgWSSendTimedOut = ffe("FF00146", "Websocket send timed out") MsgWSClosing = ffe("FF00147", "Websocket closing") MsgWSConnectFailed = ffe("FF00148", "Websocket connect failed") MsgInvalidURL = ffe("FF00149", "Invalid URL: '%s'") MsgWSHeartbeatTimeout = ffe("FF00150", "Websocket heartbeat timed out after %.2fms", 500) MsgAPIServerStartFailed = ffe("FF00151", "Unable to start listener on %s: %s") MsgInvalidCAFile = ffe("FF00152", "Invalid CA certificates file") MsgTLSConfigFailed = ffe("FF00153", "Failed to initialize TLS configuration") MsgContextCanceled = ffe("FF00154", "Context canceled") MsgConnectorFailInvoke = ffe("FF00155", "Connector request failed. requestId=%s failed to call connector API") MsgConnectorInvalidContentType = ffe("FF00156", "Connector request failed. requestId=%s invalid response content type: %s") MsgConnectorError = ffe("FF00157", "Connector request failed. requestId=%s reason=%s error: %s") MsgFieldDescriptionMissing = ffe("FF00158", "Field description missing for '%s' on route '%s'") MsgRouteDescriptionMissing = ffe("FF00159", "API route description missing for route '%s'") MsgFFStructTagMissing = ffe("FF00160", "ffstruct tag is missing for '%s' on route '%s'") MsgMultiPartFormReadError = ffe("FF00161", "Error reading multi-part form input", 400) MsgInvalidContentType = ffe("FF00162", "Invalid content type", 415) MsgFieldsAfterFile = ffe("FF00163", "Additional form field sent after file in multi-part form (ignored): '%s'", 400) Msg404NoResult = ffe("FF00164", "No result found", 404) MsgResponseMarshalError = ffe("FF00165", "Failed to serialize response data", 400) MsgRequestTimeout = ffe("FF00166", "The request with id '%s' timed out after %.2fms", 408) Msg404NotFound = ffe("FF00167", "Not found", 404) MsgUnknownAuthPlugin = ffe("FF00168", "Unknown auth plugin: '%s'") MsgForbidden = ffe("FF00170", "Forbidden", 403) MsgInvalidEnum = ffe("FF00171", "'%s' is not a valid enum type", 400) MsgInvalidEnumValue = ffe("FF00172", "'%s' is not a valid enum value for enum type '%s'. Valid options are: %v", 400) )
View Source
var ( APISuccessResponse = ffm("api.success", "Success") APIRequestTimeoutDesc = ffm("api.requestTimeout", "Server-side request timeout (milliseconds, or set a custom suffix like 10s)") )
View Source
var ArrayStringType = "`[]string`"
View Source
var BooleanType = "`boolean`"
View Source
var ByteSizeType = "[`BytesSize`](https://pkg.go.dev/github.com/docker/go-units#BytesSize)"
View Source
var FloatType = "`float32`"
View Source
var GoTemplateType = "[Go Template](https://pkg.go.dev/text/template) `string`"
View Source
var IgnoredType = "IGNORE"
View Source
var IntType = "`int`"
View Source
var MapStringStringType = "`map[string]string`"
View Source
var StringType = "`string`"
View Source
var TimeDurationType = "[`time.Duration`](https://pkg.go.dev/time#Duration)"
View Source
var TimeFormatType = "[Time format](https://pkg.go.dev/time#pkg-constants) `string`"
Functions ¶
func Expand ¶
func Expand(ctx context.Context, key MessageKey, inserts ...interface{}) string
Expand for use in docs and logging - returns a translated message, translated the language of the context If a translation is not found for the language of the context, the default language text will be returned instead
func ExpandWithCode ¶
func ExpandWithCode(ctx context.Context, key MessageKey, inserts ...interface{}) string
ExpandWithCode for use in error scenarios - returns a translated message with a "MSG012345:" prefix, translated the language of the context
func GetFieldType ¶
func GetStatusHint ¶
func NewError ¶
func NewError(ctx context.Context, msg ErrorMessageKey, inserts ...interface{}) error
NewError creates a new error
Types ¶
type ConfigMessageKey ¶
type ConfigMessageKey MessageKey
ConfigMessageKey is a special lookup string conforming to FireFly's rules for configuration descriptions and types
type ErrorMessageKey ¶
type ErrorMessageKey MessageKey
ErrorMessageKey is a special lookup string conforming to FireFly's rules for error message registration
Source Files ¶
Click to show internal directories.
Click to hide internal directories.