mongo-driver: Index | Files

package drivergen

import ""


Package Files

drivergen.go templates.go

func Initialize Uses

func Initialize() error

Initialize sets up drivergen for use. It must be called or all of the templates will be nil.

type Builtin Uses

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 Uses

func (b Builtin) Documentation() string

Documentation returns the GoDoc documentation for this built-in.

func (Builtin) ExecuteName Uses

func (b Builtin) ExecuteName() string

ExecuteName provides the name used when setting this built-in on a driver.Operation.

func (Builtin) ReferenceName Uses

func (b Builtin) ReferenceName() string

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 Uses

func (b Builtin) SetterName() string

SetterName returns the name to be used when creating a setter for this built-in.

func (Builtin) Type Uses

func (b Builtin) Type() string

Type returns the Go type for this built-in.

type BuiltinResponseType Uses

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 Command Uses

type Command struct {
    Name      string
    Parameter string
    Database  bool

Command holds the command serialization specific information for an operation.

type LegacyOperation Uses

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 Uses

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 Uses

func ParseFile(filename, packagename string) (Operation, error)

ParseFile will construct an Operation using the TOML in filename. The Operation will have the package name set to packagename.

func (Operation) CommandMethod Uses

func (op Operation) CommandMethod() (string, error)

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 Uses

func (op Operation) ConstructorFields() []string

ConstructorFields returns a slice of name name pairs that set fields in a newly instantiated operation.

func (Operation) ConstructorParameters Uses

func (op Operation) ConstructorParameters() string

ConstructorParameters builds the parameter names and types for the operation constructor.

func (Operation) EscapeDocumentation Uses

func (Operation) EscapeDocumentation(doc string) string

EscapeDocumentation will add the required // in front of each line of documentation.

func (Operation) Generate Uses

func (op Operation) Generate(w io.Writer) error

Generate creates the operation type and associated response types and writes them to w.

func (Operation) PackageName Uses

func (op Operation) PackageName() string

PackageName returns the package name to use when generating the operation.

func (Operation) ResultType Uses

func (op Operation) ResultType() string

ResultType returns the type to use as the result of running this operation.

func (Operation) ShortName Uses

func (op Operation) ShortName() string

ShortName returns the receiver used for this operation.

func (Operation) Title Uses

func (op Operation) Title(name string) string

Title wraps strings.Title for use in templates.

type Properties Uses

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 Uses

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 Uses

func (p Properties) BuiltinsMap() map[Builtin]bool

BuiltinsMap returns a map with the builtins that enabled.

func (Properties) ExecuteBuiltins Uses

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 Uses

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 Uses

func (p Properties) LegacyOperationKind() string

LegacyOperationKind returns the corresponding LegacyOperationKind value for an operation.

type RequestField Uses

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 Uses

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 Uses

func (rf RequestField) DeclarationType() string

DeclarationType returns this field's type for use in a struct type declaration.

func (RequestField) ParameterType Uses

func (rf RequestField) ParameterType() string

ParameterType returns this field's type for use as a parameter argument.

func (RequestField) PointerType Uses

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 Uses

type Response struct {
    Name  string
    Type  string
    Field map[string]ResponseField

Response represents a response type to generate.

func (Response) BuildMethod Uses

func (r Response) BuildMethod() (string, error)

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.

func (Response) ShortName Uses

func (r Response) ShortName() string

ShortName returns the short name used when constructing a response.

type ResponseField Uses

type ResponseField struct {
    Type          string
    Documentation string

ResponseField is an individual field of a response.

func (ResponseField) DeclarationType Uses

func (rf ResponseField) DeclarationType() string

DeclarationType returns the field's type for use in a struct type declaration.

type Retryable Uses

type Retryable struct {
    Mode RetryableMode
    Type RetryableType

Retryable represents retryable information for an operation.

type RetryableMode Uses

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 Uses

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.

Package drivergen imports 9 packages (graph). Updated 2019-08-24. Refresh now. Tools for package owners.