Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ dependencies = [
"sshtunnel==0.4.0",
"singer-sdk[faker,sql]~=0.50.0",
]
optional-dependencies.msgspec = [
"msgspec>=0.19.0",
]

[project.urls]
Homepage = "https://meltano.com"
Expand Down
12 changes: 12 additions & 0 deletions tap_postgres/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
if TYPE_CHECKING:
from collections.abc import Mapping, Sequence

# Try to import MsgSpecWriter for better performance
try:
from singer_sdk.contrib.msgspec import MsgSpecWriter

_MSGSPEC_AVAILABLE = True
except ImportError:
_MSGSPEC_AVAILABLE = False


REPLICATION_SLOT_PATTERN = "^(?!pg_)[A-Za-z0-9_]{1,63}$"

Expand All @@ -40,6 +48,10 @@ class TapPostgres(SQLTap):
package_name = "meltanolabs-tap-postgres"
default_stream_class = PostgresStream

# Use MsgSpecWriter if available for ~15-20% performance improvement
if _MSGSPEC_AVAILABLE:
message_writer_class = MsgSpecWriter

def __init__(
self,
*args,
Expand Down
60 changes: 51 additions & 9 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.