backendconfig

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*TopicBackendConfig topic provides updates on full backend config, via Subscribe function */
	TopicBackendConfig Topic = "backendConfig"

	/*TopicProcessConfig topic provides updates on backend config of processor enabled destinations, via Subscribe function */
	TopicProcessConfig Topic = "processConfig"

	/*TopicRegulations topic provides updates on regulations, via Subscribe function */
	TopicRegulations Topic = "regulations"

	/*RegulationSuppress refers to Suppress Regulation */
	RegulationSuppress Regulation = "Suppress"

	//TODO Will add support soon.
	/*RegulationDelete refers to Suppress and Delete Regulation */
	RegulationDelete Regulation = "Delete"

	/*RegulationSuppressAndDelete refers to Suppress and Delete Regulation */
	RegulationSuppressAndDelete Regulation = "Suppress_With_Delete"
)

Variables

View Source
var (
	LastSync           string
	LastRegulationSync string

	//DefaultBackendConfig will be initialized be Setup to either a WorkspaceConfig or MultiWorkspaceConfig.
	DefaultBackendConfig BackendConfig
	Http                 sysUtils.HttpI = sysUtils.NewHttp()

	IoUtil      sysUtils.IoUtilI         = sysUtils.NewIoUtil()
	Diagnostics diagnostics.DiagnosticsI = diagnostics.Diagnostics
)
View Source
var DefaultBackendConfigSetup = BackendConfigSetup{IsMultiWorkspace: false, MultiWorkspaceSecret: "password", ConfigBackendUrl: "https://api.rudderlabs.com", WorkSpaceToken: "", RegulationsPollInterval: 300 * time.Second, ConfigJSONPath: "/etc/rudderstack/workspaceConfig.json", ConfigFromFile: false, MaxRegulationsPerRequest: 1000, ConfigEnvReplacementEnabled: true, ErrorFilePath: "/tmp/error_store.json", ConfigLogger: logger.DefaultConfigLogger, ConfigStats: stats.DefaultConfigStats, ConfigDiagnostics: diagnostics.DefaultConfigDiagnostics}

Functions

func GetWorkspaceIDForWriteKey

func GetWorkspaceIDForWriteKey(writeKey string) string

func MakeBackendPostRequest

func MakeBackendPostRequest(endpoint string, data interface{}) (response []byte, ok bool)

func MakePostRequest

func MakePostRequest(url string, endpoint string, data interface{}) (response []byte, ok bool)

func Setup

func Setup(pollRegulations bool, configEnvHandler types.ConfigEnvI, configList ...interface{})

Setup ... LoadConfig and Setup or Call Setup and initialise LoadConfig in this

func Subscribe

func Subscribe(channel chan utils.DataEvent, topic Topic)

Subscribe subscribes a channel to a specific topic of backend config updates. Deprecated: Use an instance of BackendConfig instead of static function

func WaitForConfig

func WaitForConfig()

WaitForConfig waits until backend config has been initialized Deprecated: Use an instance of BackendConfig instead of static function

Types

type BackendConfig

type BackendConfig interface {
	SetUp()
	Get() (ConfigT, bool)
	GetRegulations() (RegulationsT, bool)
	GetWorkspaceIDForWriteKey(string) string
	GetWorkspaceLibrariesForWorkspaceID(string) LibrariesT
	WaitForConfig()
	Subscribe(channel chan utils.DataEvent, topic Topic)
}

type BackendConfigAdmin

type BackendConfigAdmin struct{}

BackendConfigAdmin is container object to expose admin functions

func (*BackendConfigAdmin) RoutingConfig

func (bca *BackendConfigAdmin) RoutingConfig(filterProcessor bool, reply *string) (err error)

RoutingConfig reports current backend config and process config after masking secret fields

type BackendConfigSetup

type BackendConfigSetup struct {
	IsMultiWorkspace            bool
	MultiWorkspaceSecret        string
	ConfigBackendUrl            string
	WorkSpaceToken              string
	PollInterval                time.Duration
	RegulationsPollInterval     time.Duration
	ConfigJSONPath              string
	ConfigFromFile              bool
	MaxRegulationsPerRequest    int
	ConfigEnvReplacementEnabled bool
	ErrorFilePath               string
	ConfigLogger                logger.ConfigLogger
	ConfigStats                 stats.ConfigStats
	ConfigDiagnostics           diagnostics.ConfigDiagnostics
}

type CommonBackendConfig

type CommonBackendConfig struct {
	// contains filtered or unexported fields
}

func (*CommonBackendConfig) Subscribe

func (bc *CommonBackendConfig) Subscribe(channel chan utils.DataEvent, topic Topic)

Subscribe subscribes a channel to a specific topic of backend config updates. Channel will receive a new utils.DataEvent each time the backend configuration is updated. Data of the DataEvent should be a backendconfig.ConfigT struct. Available topics are: - TopicBackendConfig: Will receive complete backend configuration - TopicProcessConfig: Will receive only backend configuration of processor enabled destinations - TopicRegulations: Will receeive all regulations

func (*CommonBackendConfig) WaitForConfig

func (bc *CommonBackendConfig) WaitForConfig()

WaitForConfig waits until backend config has been initialized

type ConfigT

type ConfigT struct {
	EnableMetrics bool       `json:"enableMetrics"`
	WorkspaceID   string     `json:"workspaceId"`
	Sources       []SourceT  `json:"sources"`
	Libraries     LibrariesT `json:"libraries"`
}

func GetConfig

func GetConfig() ConfigT

type DestinationDefinitionT

type DestinationDefinitionT struct {
	ID            string
	Name          string
	DisplayName   string
	Config        map[string]interface{}
	ResponseRules map[string]interface{}
}

type DestinationT

type DestinationT struct {
	ID                    string
	Name                  string
	DestinationDefinition DestinationDefinitionT
	Config                map[string]interface{}
	Enabled               bool
	Transformations       []TransformationT
	IsProcessorEnabled    bool
}

type HostedWorkspacesT

type HostedWorkspacesT struct {
	HostedWorkspaces []WorkspaceT `json:"workspaces"`
}

type LibrariesT

type LibrariesT []LibraryT

func GetWorkspaceLibrariesForWorkspaceID

func GetWorkspaceLibrariesForWorkspaceID(workspaceId string) LibrariesT

type LibraryT

type LibraryT struct {
	VersionID string
}

type MultiWorkspaceConfig

type MultiWorkspaceConfig struct {
	CommonBackendConfig
	// contains filtered or unexported fields
}

MultiWorkspaceConfig is a struct to hold variables necessary for supporting multiple workspaces.

func (*MultiWorkspaceConfig) Get

func (multiWorkspaceConfig *MultiWorkspaceConfig) Get() (ConfigT, bool)

Get returns sources from all hosted workspaces

func (*MultiWorkspaceConfig) GetRegulations

func (multiWorkspaceConfig *MultiWorkspaceConfig) GetRegulations() (RegulationsT, bool)

GetRegulations returns regulations from all hosted workspaces

func (*MultiWorkspaceConfig) GetWorkspaceIDForWriteKey

func (multiWorkspaceConfig *MultiWorkspaceConfig) GetWorkspaceIDForWriteKey(writeKey string) string

GetWorkspaceIDForWriteKey returns workspaceID for the given writeKey

func (*MultiWorkspaceConfig) GetWorkspaceLibrariesForWorkspaceID

func (multiWorkspaceConfig *MultiWorkspaceConfig) GetWorkspaceLibrariesForWorkspaceID(workspaceID string) LibrariesT

GetWorkspaceLibrariesForWorkspaceID returns workspaceLibraries for workspaceID

func (*MultiWorkspaceConfig) SetUp

func (multiWorkspaceConfig *MultiWorkspaceConfig) SetUp()

SetUp sets up MultiWorkspaceConfig

type Regulation

type Regulation string

type RegulationsT

type RegulationsT struct {
	WorkspaceRegulations []WorkspaceRegulationT `json:"workspaceRegulations"`
	SourceRegulations    []SourceRegulationT    `json:"sourceRegulations"`
}

type SRegulationsT

type SRegulationsT struct {
	SourceRegulations []SourceRegulationT `json:"sourceRegulations"`
	Start             int                 `json:"start"`
	Limit             int                 `json:"limit"`
	Size              int                 `json:"size"`
	End               bool                `json:"end"`
	Next              int                 `json:"next"`
}

type SourceDefinitionT

type SourceDefinitionT struct {
	ID       string
	Name     string
	Category string
}

type SourceRegulationT

type SourceRegulationT struct {
	ID             string
	RegulationType string
	WorkspaceID    string
	SourceID       string
	UserID         string
}

type SourceT

type SourceT struct {
	ID               string
	Name             string
	SourceDefinition SourceDefinitionT
	Config           map[string]interface{}
	Enabled          bool
	WorkspaceID      string
	Destinations     []DestinationT
	WriteKey         string
}

type Topic

type Topic string

Topic refers to a subset of backend config's updates, received after subscribing using the backend config's Subscribe function.

type TransformationT

type TransformationT struct {
	VersionID string
}

type WRegulationsT

type WRegulationsT struct {
	WorkspaceRegulations []WorkspaceRegulationT `json:"workspaceRegulations"`
	Start                int                    `json:"start"`
	Limit                int                    `json:"limit"`
	Size                 int                    `json:"size"`
	End                  bool                   `json:"end"`
	Next                 int                    `json:"next"`
}

type WorkspaceConfig

type WorkspaceConfig struct {
	CommonBackendConfig
	// contains filtered or unexported fields
}

func (*WorkspaceConfig) Get

func (workspaceConfig *WorkspaceConfig) Get() (ConfigT, bool)

Get returns sources from the workspace

func (*WorkspaceConfig) GetRegulations

func (workspaceConfig *WorkspaceConfig) GetRegulations() (RegulationsT, bool)

GetRegulations returns sources from the workspace

func (*WorkspaceConfig) GetWorkspaceIDForWriteKey

func (workspaceConfig *WorkspaceConfig) GetWorkspaceIDForWriteKey(writeKey string) string

func (*WorkspaceConfig) GetWorkspaceLibrariesForWorkspaceID

func (workspaceConfig *WorkspaceConfig) GetWorkspaceLibrariesForWorkspaceID(workspaceID string) LibrariesT

GetWorkspaceLibrariesFromWorkspaceID returns workspaceLibraries for workspaceID

func (*WorkspaceConfig) SetUp

func (workspaceConfig *WorkspaceConfig) SetUp()

type WorkspaceRegulationT

type WorkspaceRegulationT struct {
	ID             string
	RegulationType string
	WorkspaceID    string
	UserID         string
}

type WorkspaceRegulationsT

type WorkspaceRegulationsT struct {
	WorkspaceRegulationsMap map[string]RegulationsT `json:"-"`
}

WorkspaceRegulationsT holds regulations of workspaces

type WorkspaceT

type WorkspaceT struct {
	WorkspaceID string `json:"id"`
}

type WorkspacesT

type WorkspacesT struct {
	WorkspaceSourcesMap map[string]ConfigT `json:"-"`
}

WorkspacesT holds sources of workspaces

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL