Documentation ¶
Index ¶
- func Initialize() error
- type Builtin
- type BuiltinResponseType
- type Command
- type LegacyOperation
- type Operation
- func (op Operation) CommandMethod() (string, error)
- func (op Operation) ConstructorFields() []string
- func (op Operation) ConstructorParameters() string
- func (Operation) EscapeDocumentation(doc string) string
- func (op Operation) Generate(w io.Writer) error
- func (op Operation) PackageName() string
- func (op Operation) ResultType() string
- func (op Operation) ShortName() string
- func (op Operation) Title(name string) string
- type Properties
- type RequestField
- type Response
- type ResponseField
- type Retryable
- type RetryableMode
- type RetryableType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func Initialize() error
Initialize sets up drivergen for use. It must be called or all of the templates will be nil.
Types ¶
type Builtin ¶
type Builtin string
Builtin represent types that are built into the IDL.
const ( Collection Builtin = "collection" ReadPreference Builtin = "read preference" ReadConcern Builtin = "read concern" WriteConcern Builtin = "write concern" CommandMonitor Builtin = "command monitor" ClientSession Builtin = "client session" ClusterClock Builtin = "cluster clock" Selector Builtin = "selector" Database Builtin = "database" Deployment Builtin = "deployment" Crypt Builtin = "crypt" )
These constants are the built in types.
func (Builtin) Documentation ¶
Documentation returns the GoDoc documentation for this built-in.
func (Builtin) ExecuteName ¶
ExecuteName provides the name used when setting this built-in on a driver.Operation.
func (Builtin) ReferenceName ¶
ReferenceName returns the short name used to refer to this built in. It is used as the field name in the struct and as the variable name for the setter.
func (Builtin) SetterName ¶
SetterName returns the name to be used when creating a setter for this built-in.
type BuiltinResponseType ¶
type BuiltinResponseType string
BuiltinResponseType is the type used to define built in response types.
const (
BatchCursor BuiltinResponseType = "batch cursor"
)
These constants represents the different built in response types.
type LegacyOperation ¶
type LegacyOperation string
LegacyOperation enables legacy versions of find, getMore, or killCursors operations.
const ( LegacyFind LegacyOperation = "find" LegacyGetMore LegacyOperation = "getMore" LegacyKillCursors LegacyOperation = "killCursors" LegacyListCollections LegacyOperation = "listCollections" LegacyListIndexes LegacyOperation = "listIndexes" )
These constants are the various legacy operations that can be generated.
type Operation ¶
type Operation struct { Name string Documentation string Version int DriverInternal bool Properties Properties Command Command Request map[string]RequestField Response Response // contains filtered or unexported fields }
Operation is the top-level configuration type. It's the direct representation of an operation TOML file.
func ParseFile ¶
ParseFile will construct an Operation using the TOML in filename. The Operation will have the package name set to packagename.
func (Operation) CommandMethod ¶
CommandMethod returns the code required to transform the operation into a command. This code only returns the contents of the command method, without the function definition and return.
func (Operation) ConstructorFields ¶
ConstructorFields returns a slice of name name pairs that set fields in a newly instantiated operation.
func (Operation) ConstructorParameters ¶
ConstructorParameters builds the parameter names and types for the operation constructor.
func (Operation) EscapeDocumentation ¶
EscapeDocumentation will add the required // in front of each line of documentation.
func (Operation) Generate ¶
Generate creates the operation type and associated response types and writes them to w.
func (Operation) PackageName ¶
PackageName returns the package name to use when generating the operation.
func (Operation) ResultType ¶
ResultType returns the type to use as the result of running this operation.
type Properties ¶
type Properties struct { Disabled []Builtin Enabled []Builtin Retryable Retryable Batches string Legacy LegacyOperation MinimumWriteConcernWireVersion int MinimumReadConcernWireVersion int }
Properties represent general properties of the operation.
func (Properties) Builtins ¶
func (p Properties) Builtins() []Builtin
Builtins returns a slice of built-ins that is the combination of the non-disabled default built-ins plus any enabled non-default built-ins.
func (Properties) BuiltinsMap ¶
func (p Properties) BuiltinsMap() map[Builtin]bool
BuiltinsMap returns a map with the builtins that enabled.
func (Properties) ExecuteBuiltins ¶
func (p Properties) ExecuteBuiltins() []Builtin
ExecuteBuiltins returns the builtins that need to be set on the driver.Operation for the properties set.
func (Properties) IsEnabled ¶
func (p Properties) IsEnabled(builtin string) Builtin
IsEnabled returns a Builtin if the string that matches that built-in is enabled. If it's not, an empty string is returned.
func (Properties) LegacyOperationKind ¶
func (p Properties) LegacyOperationKind() string
LegacyOperationKind returns the corresponding LegacyOperationKind value for an operation.
type RequestField ¶
type RequestField struct { Type string Slice bool Constructor bool Variadic bool Skip bool Documentation string MinWireVersion int MinWireVersionRequired int KeyName string }
RequestField represents an individual operation field.
func (RequestField) Command ¶
func (rf RequestField) Command(name, accessor string) string
Command returns a string function that sets the key to name and value to the RequestField type. It uses accessor to access the parameter. The accessor parameter should be the shortname of the operation and the name of the field of the property used for the command name. For example, if the shortname is "eo" and the field is "collection" then accessor should be "eo.collection".
func (RequestField) DeclarationType ¶
func (rf RequestField) DeclarationType() string
DeclarationType returns this field's type for use in a struct type declaration.
func (RequestField) ParameterType ¶
func (rf RequestField) ParameterType() string
ParameterType returns this field's type for use as a parameter argument.
func (RequestField) PointerType ¶
func (rf RequestField) PointerType() bool
PointerType returns true if the request field is a pointer type and the setter should take the address when setting via a setter method.
type Response ¶
type Response struct { Name string Type string Field map[string]ResponseField }
Response represents a response type to generate.
func (Response) BuildMethod ¶
BuildMethod handles creating the body of a method to create a response from a BSON response document.
TODO(GODRIVER-1094): This method is hacky because we're not using nested templates like we should be. Each template should be registered and we should be calling the template to create it.
type ResponseField ¶
ResponseField is an individual field of a response.
func (ResponseField) DeclarationType ¶
func (rf ResponseField) DeclarationType() string
DeclarationType returns the field's type for use in a struct type declaration.
type Retryable ¶
type Retryable struct { Mode RetryableMode Type RetryableType }
Retryable represents retryable information for an operation.
type RetryableMode ¶
type RetryableMode string
RetryableMode are the configuration representations of the retryability modes.
const ( RetryableOnce RetryableMode = "once" RetryableOncePerCommand RetryableMode = "once per command" RetryableContext RetryableMode = "context" )
These constants are the various retryability modes.
type RetryableType ¶
type RetryableType string
RetryableType instances are the configuration representation of a kind of retryability.
const ( RetryableWrites RetryableType = "writes" RetryableReads RetryableType = "reads" )
These constants are the various retryable types.