Skip to content

Commit ba46ec3

Browse files
authored
Merge pull request #106 from trimble-oss/trcdb_refactor
Refactor buildopts into tierceron-core
2 parents 5989658 + 8ac02b9 commit ba46ec3

13 files changed

Lines changed: 297 additions & 15 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package flowcoreopts
2+
3+
const (
4+
DataflowTestNameColumn = "flowName"
5+
DataflowGroupTestNameColumn = "flowGroup"
6+
DataflowTestIdColumn = "argosId"
7+
DataflowTestStateCodeColumn = "stateCode"
8+
)
9+
10+
type Option func(*OptionsBuilder)
11+
12+
type OptionsBuilder struct {
13+
GetIdColumnType func(table string) any
14+
}
15+
16+
func LoadOptions() Option {
17+
return func(optionsBuilder *OptionsBuilder) {
18+
optionsBuilder.GetIdColumnType = GetIdColumnType
19+
}
20+
}
21+
22+
var BuildOptions *OptionsBuilder
23+
24+
func NewOptionsBuilder(opts ...Option) {
25+
BuildOptions = &OptionsBuilder{}
26+
for _, opt := range opts {
27+
opt(BuildOptions)
28+
}
29+
}
30+
31+
func GetIdColumnType(table string) any {
32+
return nil
33+
}
34+
35+
func IsCreateTableEnabled() bool {
36+
return false
37+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package flowopts
2+
3+
import flowcore "github.com/trimble-oss/tierceron-core/v2/flow"
4+
5+
type Option func(*OptionsBuilder)
6+
7+
type OptionsBuilder struct {
8+
AllowTrcdbInterfaceOverride func() bool
9+
GetAdditionalFlows func() []flowcore.FlowDefinition
10+
GetAdditionalTestFlows func() []flowcore.FlowDefinition
11+
GetAdditionalFlowsByState func(string) []flowcore.FlowDefinition
12+
ProcessTestFlowController func(tfmContext flowcore.FlowMachineContext, tfContext flowcore.FlowContext) error
13+
ProcessFlowController func(tfmContext flowcore.FlowMachineContext, tfContext flowcore.FlowContext) error
14+
GetFlowMachineTemplates func() map[string]any
15+
}
16+
17+
var BuildOptions *OptionsBuilder
18+
19+
func NewOptionsBuilder(opts ...Option) {
20+
BuildOptions = &OptionsBuilder{}
21+
for _, opt := range opts {
22+
opt(BuildOptions)
23+
}
24+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package testopts
2+
3+
import flowcore "github.com/trimble-oss/tierceron-core/v2/flow"
4+
5+
type Option func(*OptionsBuilder)
6+
7+
type OptionsBuilder struct {
8+
GetAdditionalTestFlows func() []flowcore.FlowDefinition
9+
GetAdditionalFlowsByState func(teststate string) []flowcore.FlowDefinition
10+
ProcessTestFlowController func(tfmContext flowcore.FlowMachineContext, tfContext flowcore.FlowContext) error
11+
GetTestConfig func(tokenPtr *string, wantPluginPaths bool) map[string]any
12+
}
13+
14+
var BuildOptions *OptionsBuilder
15+
16+
func NewOptionsBuilder(opts ...Option) {
17+
BuildOptions = &OptionsBuilder{}
18+
for _, opt := range opts {
19+
opt(BuildOptions)
20+
}
21+
}

buildopts/buildopts.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package buildopts
2+
3+
import "database/sql"
4+
5+
type Option func(*OptionsBuilder)
6+
7+
type OptionsBuilder struct {
8+
SetLogger func(logger any)
9+
SetErrorLogger func(logger any)
10+
11+
GetLocalVaultAddr func() string
12+
GetSupportedSourceRegions func() []string
13+
GetTestDeployConfig func(tokenPtr *string) map[string]any
14+
ProcessPluginEnvConfig func(pluginEnvConfig map[string]any) map[string]any
15+
GetExtensionAuthComponents func(config map[string]any) map[string]any
16+
GetSyncedTables func() []string
17+
Authorize func(db *sql.DB, userIdentifier string, userPassword string) (bool, string, error)
18+
CheckMemLock func(bucket string, key string) bool
19+
GetTrcDbUrl func(data map[string]any) string
20+
}
21+
22+
var BuildOptions *OptionsBuilder
23+
24+
func NewOptionsBuilder(opts ...Option) {
25+
BuildOptions = &OptionsBuilder{}
26+
for _, opt := range opts {
27+
opt(BuildOptions)
28+
}
29+
}

buildopts/coreopts/buildopts.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package coreopts
2+
3+
import (
4+
"database/sql"
5+
6+
flowcore "github.com/trimble-oss/tierceron-core/v2/flow"
7+
)
8+
9+
type Option func(*OptionsBuilder)
10+
11+
type OptionsBuilder struct {
12+
GetFolderPrefix func(custom []string) string
13+
GetSupportedTemplates func(custom []string) []string
14+
GetVaultInstallRoot func() string
15+
IsLocalEndpoint func(addr string) bool
16+
GetSupportedDomains func(bool) []string
17+
GetSupportedEndpoints func(bool) [][]string
18+
GetLocalHost func() string
19+
GetRegionByHost func(hostName string) string
20+
GetDefaultRegion func() string
21+
GetVaultHost func() string
22+
GetVaultHostPort func() string
23+
GetUserNameField func() string
24+
GetUserCodeField func() string
25+
ActiveSessions func(db *sql.DB) ([]map[string]any, error)
26+
GetSyncedTables func() []string
27+
IsSupportedFlow func(flowName string) bool
28+
GetDatabaseName func(flumeDbType flowcore.FlumeDbType) string
29+
FindIndexForService func(tfmContext flowcore.FlowMachineContext, project string, service string) (string, []string, string, error)
30+
DecryptSecretConfig func(map[string]any, map[string]any) (string, error)
31+
GetDFSPathName func() (string, string)
32+
CompareLastModified func(dfStatMapA map[string]any, dfStatMapB map[string]any) bool
33+
PreviousStateCheck func(currentState int) int
34+
GetMachineID func() string
35+
InitPluginConfig func(pluginEnvConfig map[string]any) map[string]any
36+
GetPluginRestrictedMappings func() map[string][][]string
37+
GetSupportedCertIssuers func() []string
38+
}
39+
40+
var BuildOptions *OptionsBuilder
41+
42+
func NewOptionsBuilder(opts ...Option) {
43+
BuildOptions = &OptionsBuilder{}
44+
for _, opt := range opts {
45+
opt(BuildOptions)
46+
}
47+
}

buildopts/deployopts/buildopts.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package deployopts
2+
3+
type Option func(*OptionsBuilder)
4+
5+
type OptionsBuilder struct {
6+
InitSupportedDeployers func(supportedDeployers []string) []string
7+
GetDecodedDeployerId func(sessionId string) (string, bool)
8+
GetEncodedDeployerId func(deployment string, env string) (string, bool)
9+
}
10+
11+
var BuildOptions *OptionsBuilder
12+
13+
func NewOptionsBuilder(opts ...Option) {
14+
BuildOptions = &OptionsBuilder{}
15+
for _, opt := range opts {
16+
opt(BuildOptions)
17+
}
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package harbingeropts
2+
3+
import flowcore "github.com/trimble-oss/tierceron-core/v2/flow"
4+
5+
type Option func(*OptionsBuilder)
6+
7+
type OptionsBuilder struct {
8+
GetIdColumnType func(table string) any
9+
GetFolderPrefix func(custom []string) string
10+
IsValidProjectName func(projectName string) bool
11+
BuildTableGrant func(tableName string) (string, error)
12+
TableGrantNotify func(tfmContext flowcore.FlowMachineContext, tableName string)
13+
}
14+
15+
var BuildOptions *OptionsBuilder
16+
17+
func NewOptionsBuilder(opts ...Option) {
18+
BuildOptions = &OptionsBuilder{}
19+
for _, opt := range opts {
20+
opt(BuildOptions)
21+
}
22+
}

buildopts/tcopts/buildopts.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tcopts
2+
3+
type Option func(*OptionsBuilder)
4+
5+
type OptionsBuilder struct {
6+
CheckIncomingColumnName func(col string) bool
7+
CheckFlowDataIncoming func(secretColumns map[string]string, secretValue string, dbName string, tableName string) ([]byte, string, string, string, error)
8+
CheckIncomingAliasColumnName func(col string) bool
9+
GetTrcDbUrl func(data map[string]any) string
10+
}
11+
12+
var BuildOptions *OptionsBuilder
13+
14+
func NewOptionsBuilder(opts ...Option) {
15+
BuildOptions = &OptionsBuilder{}
16+
for _, opt := range opts {
17+
opt(BuildOptions)
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package xencryptopts
2+
3+
type Option func(*OptionsBuilder)
4+
5+
type OptionsBuilder struct {
6+
SetEncryptionSecret func(string) error
7+
MakeNewEncryption func() (string, string, error)
8+
Encrypt func(input string, encryption map[string]any) (string, error)
9+
Decrypt func(passStr string, decryption map[string]any) (string, error)
10+
}
11+
12+
var BuildOptions *OptionsBuilder
13+
14+
func NewOptionsBuilder(opts ...Option) {
15+
BuildOptions = &OptionsBuilder{}
16+
for _, opt := range opts {
17+
opt(BuildOptions)
18+
}
19+
}

flow/doc.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Package flow provides the foundational flow processing framework for Tierceron Core.
2+
//
3+
// This package defines the core abstractions and interfaces for building data flow
4+
// pipelines. It includes:
5+
// - Flow machine initialization and lifecycle management
6+
// - Generic flow processing capabilities
7+
// - Flow context definitions and interfaces
8+
// - Flow execution and orchestration
9+
// - Plugin integration points
10+
//
11+
// The flow framework enables building complex data processing pipelines that can
12+
// transform, route, and process data through multiple stages, with support for
13+
// both stateful and stateless operations.
14+
package flow

0 commit comments

Comments
 (0)