MCPcopy Create free account
hub / github.com/amp-labs/connectors / WithModule

Method WithModule

common/paramsbuilder/module.go:34–44  ·  view source on GitHub ↗

WithModule allows API module selection. Connector implementation must provide list of modules that are currently supported. This defines a list of module a user could switch to. Any out of scope module will be ignored. If user supplied unsupported module, then it will use this fallback.

(moduleID common.ModuleID, supported common.Modules, fallbackID common.ModuleID)

Source from the content-addressed store, hash-verified

32// This defines a list of module a user could switch to. Any out of scope module will be ignored.
33// If user supplied unsupported module, then it will use this fallback.
34func (p *Module) WithModule(moduleID common.ModuleID, supported common.Modules, fallbackID common.ModuleID) {
35 modules := datautils.NewDefaultMap(supported,
36 func(unknownID common.ModuleID) common.Module {
37 // Unknown module ids will receive a fallback module.
38 return supported[fallbackID]
39 },
40 )
41
42 p.Selection = modules.Get(moduleID)
43 p.supported = supported
44}

Callers 3

WithModuleFunction · 0.80
WithModuleFunction · 0.80
WithModuleFunction · 0.80

Calls 2

NewDefaultMapFunction · 0.92
GetMethod · 0.65

Tested by

no test coverage detected