Skip to content

Conversation

@Anudhyan
Copy link

Title

constants: centralize GLOBAL state support list and use helper in catalog delta (Fixes #601)

Description

This PR centralizes the definition of which connectors support GLOBAL state and updates the catalog delta computation to reference that centralized list instead of hard-coding checks.

Changes:

  • Introduced constants.GlobalStateSupportedDrivers: []DriverType{Postgres, MySQL}.
  • Added constants.IsGlobalStateSupported(connectorType string) bool.
  • Updated types/catalog.go to use constants.IsGlobalStateSupported(connectorType) in place of the hard-coded Postgres || MySQL check in the “GetStreamsDelta” logic.

Motivation:

  • Avoids scattered driver-type conditionals across the codebase.
  • Simplifies future updates (e.g., if Oracle or others gain GLOBAL state support) by adjusting a single list in constants.

Closes #601.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Build and basic checks
    • go build ./... succeeds (no import changes needed in types/catalog.go).
  • Behavior parity validation
    • The previous logic (Postgres OR MySQL) now routes through IsGlobalStateSupported, returning identical results for current connectors.
  • Manual smoke (optional)
    • Run discover and ensure the catalog delta behavior for a Postgres/MySQL source is unchanged.
    • Run discover for MongoDB and verify no GLOBAL-only assumptions are applied.

Screenshots or Recordings

N/A

Documentation

  • N/A (refactor/small enhancement only)
  • Documentation Link: [link to README, olake.io/docs, or olake-docs]

Related PRs (If Any)

N/A

Implementation details

  • Added in constants/constants.go:
    • GlobalStateSupportedDrivers: []DriverType{Postgres, MySQL}
    • IsGlobalStateSupported(connectorType string) bool
  • Updated in types/catalog.go:
    • Replaced:
      • connectorType == string(constants.Postgres) || connectorType == string(constants.MySQL)
    • With:
      • constants.IsGlobalStateSupported(connectorType)

Backward compatibility

  • No behavioral changes intended; this only centralizes the logic in constants and maintains the same outcomes for existing connectors.

Added support for checking if a connector type supports GLOBAL state.

Signed-off-by: Anudhyan Datta <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Oct 31, 2025

CLA assistant check
All committers have signed the CLA.

Refactor globalStateSupportedConnector check to use constants.

Signed-off-by: Anudhyan Datta <[email protected]>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the PR must be made from staging, not master. Please read the contribution docs at olake.io/docs

var GlobalStateSupportedDrivers = []DriverType{Postgres, MySQL}

// IsGlobalStateSupported reports whether the given connector type supports GLOBAL state
func IsGlobalStateSupported(connectorType string) bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this function from constants.go. constants.go is static page which should have no computation based methods.

// TODO: create an array of global state supported connectors in constants
globalStateSupportedConnector := connectorType == string(constants.Postgres) || connectorType == string(constants.MySQL)
// flag for connectors which have global state support (centralized in constants)
globalStateSupportedConnector := constants.IsGlobalStateSupported(connectorType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you are calling a loop to check the bool. but previously it was a simple OR. this is bit overkill I believe. please do change accordingly. try to use OR itself.

@vaibhav-datazip
Copy link
Collaborator

hi @Anudhyan , will be closing this pr if you are no longer working on this.

@Anudhyan
Copy link
Author

Anudhyan commented Nov 5, 2025

hi @Anudhyan , will be closing this pr if you are no longer working on this.

i am working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create an array of global state supported connectors in constants

4 participants