Documentation
¶
Index ¶
- Constants
- func GatewayEdiJavaDefaultParams() map[string]string
- func RegisterScooper(name string, m func() Scooper)
- type GatewayEdiSftpScooper
- type Scooper
- type ScooperResult
- type SftpScooper
- func (s *SftpScooper) GetEnabledConfigValue() string
- func (s *SftpScooper) PostProcess(data []byte, filename string) ([]byte, error)
- func (s *SftpScooper) Scoop() ([]ScooperResult, error)
- func (s *SftpScooper) SetContext(ctx context.Context) error
- func (s *SftpScooper) SetParameters(params map[string]string) error
- func (s *SftpScooper) SetUsername(user string) error
Constants ¶
const ( GatewayEdiJavaDefaultHost = "sftp.gatewayedi.com" GatewayEdiJavaDefaultPort = 22 GatewayEdiJavaDefaultPath = "remits" )
The 0.5.x Java original hardcoded its vendor connection in GatewayEdiSftpScooper.java:52-62 — getHost() returned "sftp.gatewayedi.com", getPort() 22 and getPath() "remits" — so a Java-built GatewayEDI scooper was always configured.
The Go port does not assume them: silently pointing a fresh scooper at a vendor endpoint would be a surprise, and the plugin loader only reads the parameters a caller stored in tUserConfig. They are recorded here (not invented) for migrations and for callers that want them, and they take effect only when supplied explicitly — through SetParameters, or by way of GatewayEdiJavaDefaultParams.
const GatewayEdiKeyName = "GatewayEDI"
const GatewayEdiScooperClass = "org.remitt.plugin.scooper.GatewayEdiSftpScooper"
const GatewayEdiScooperEnabled = "org.remitt.plugin.scooper.GatewayEdiSftpScooper.enabled"
const SftpScooperClass = "org.remitt.plugin.scooper.SftpScooper"
const SftpScooperEnabled = "org.remitt.plugin.scooper.SftpScooper.enabled"
Variables ¶
This section is empty.
Functions ¶
func GatewayEdiJavaDefaultParams ¶
GatewayEdiJavaDefaultParams returns the connection parameters the Java original hardcoded, for a caller or migration that wants to opt in explicitly. It is never applied implicitly: a GatewayEDI scooper with no parameters stays unconfigured and fails Scoop with the host/port error.
func RegisterScooper ¶
RegisterScooper registers a scooper factory function under the given name.
Types ¶
type GatewayEdiSftpScooper ¶
type GatewayEdiSftpScooper struct {
SftpScooper
}
GatewayEdiSftpScooper extends SftpScooper by adding PGP decryption for files downloaded from GatewayEDI's SFTP server.
func (*GatewayEdiSftpScooper) GetEnabledConfigValue ¶
func (g *GatewayEdiSftpScooper) GetEnabledConfigValue() string
GetEnabledConfigValue returns the config key that enables this scooper.
func (*GatewayEdiSftpScooper) PostProcess ¶
func (g *GatewayEdiSftpScooper) PostProcess(data []byte, filename string) ([]byte, error)
PostProcess decrypts the PGP payload of a remittance file with the user's stored GatewayEDI private key. Content that is already readable remittance data (XML, X12, plain text) is returned verbatim and never costs a keyring lookup.
func (*GatewayEdiSftpScooper) Scoop ¶
func (g *GatewayEdiSftpScooper) Scoop() ([]ScooperResult, error)
Scoop overrides the embedded SftpScooper.Scoop only to hand the file loop the outer scooper as its content processor.
Go has no virtual dispatch for embedded structs: without this method a call to g.Scoop() would run (*SftpScooper).Scoop with the embedded SftpScooper as receiver, which statically calls (*SftpScooper).PostProcess, and the decrypting PostProcess below — the whole point of this subclass, and what GatewayEdiSftpScooper.java:64-70 relies on — would never run. Remittances would then be stored as raw ciphertext.
func (*GatewayEdiSftpScooper) SetContext ¶
func (g *GatewayEdiSftpScooper) SetContext(ctx context.Context) error
SetContext sets the execution context.
type Scooper ¶
type Scooper interface {
// Scoop polls the remote source and returns results for files not yet processed.
Scoop() ([]ScooperResult, error)
// SetParameters configures the scooper with plugin options.
SetParameters(params map[string]string) error
// SetUsername sets the user owning this scooper run.
SetUsername(user string) error
// GetEnabledConfigValue returns the config key that enables/disables this scooper.
GetEnabledConfigValue() string
// SetContext sets the execution context.
SetContext(context.Context) error
}
Scooper is the interface for scooper plugins that poll remote sources.
func InstantiateScooper ¶
InstantiateScooper creates a new scooper instance by registered name.
The lookup takes scooperRegistryLock, the same lock RegisterScooper writes under: an unsynchronised map read racing a registration is a runtime fatal error ("concurrent map read and map write"), not a recoverable panic. The factory is called after the lock is released, so a slow or re-entrant factory cannot block registrations.
type ScooperResult ¶
type ScooperResult struct {
Filename string `json:"filename"`
Host string `json:"host"`
Path string `json:"path"`
Content []byte `json:"content"`
}
ScooperResult holds the result of a single file scooped from a remote source.
type SftpScooper ¶
type SftpScooper struct {
// contains filtered or unexported fields
}
SftpScooper polls an SFTP server for new files, downloading and storing them in the tScooper table. Previously scooped files (by filename) are skipped.
func (*SftpScooper) GetEnabledConfigValue ¶
func (s *SftpScooper) GetEnabledConfigValue() string
GetEnabledConfigValue returns the configuration key that controls whether this scooper is enabled.
func (*SftpScooper) PostProcess ¶
func (s *SftpScooper) PostProcess(data []byte, filename string) ([]byte, error)
PostProcess provides a hook for subclasses to transform downloaded content. Default implementation returns data unchanged.
func (*SftpScooper) Scoop ¶
func (s *SftpScooper) Scoop() ([]ScooperResult, error)
Scoop connects to the configured SFTP server, lists files in the target directory, and downloads any that haven't been scooped before. The base implementation passes itself as the content processor; a subclass that overrides PostProcess overrides Scoop to pass itself instead.
func (*SftpScooper) SetContext ¶
func (s *SftpScooper) SetContext(ctx context.Context) error
SetContext sets the execution context.
func (*SftpScooper) SetParameters ¶
func (s *SftpScooper) SetParameters(params map[string]string) error
SetParameters configures the scooper from a key-value parameter map. Expected keys: sftpUsername, sftpPassword, sftpHost, sftpPort, sftpPath.
A malformed sftpPort is recorded rather than silently truncated, zeroed or accepted as negative; it is reported by validateConfig and therefore by Scoop. The return value stays nil: it is not what the plugin loader inspects, and callers rely on the setters never failing.
func (*SftpScooper) SetUsername ¶
func (s *SftpScooper) SetUsername(user string) error
SetUsername sets the user owning this scooper run.