Class PostgresPlugin.Builder
java.lang.Object
com.google.genkit.plugins.postgresql.PostgresPlugin.Builder
- Enclosing class:
PostgresPlugin
Builder for PostgresPlugin.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTable(PostgresTableConfig tableConfig) Adds a table configuration.build()Builds the PostgresPlugin.connectionString(String connectionString) Sets the JDBC connection string (required unless externalDataSource is provided).dataSource(DataSource dataSource) Sets an external DataSource to use instead of creating one.hikariProperty(String key, Object value) Sets a HikariCP connection pool property.static PostgresPlugin.BuilderCreates a builder configured for a local PostgreSQL instance.Sets the database password.Sets the database username.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
connectionString
Sets the JDBC connection string (required unless externalDataSource is provided).Example: "jdbc:postgresql://localhost:5432/mydb"
-
username
Sets the database username. -
password
Sets the database password. -
addTable
Adds a table configuration. -
hikariProperty
Sets a HikariCP connection pool property.Common properties:
- maximumPoolSize - maximum pool size (default: 10)
- minimumIdle - minimum idle connections (default: 2)
- connectionTimeout - connection timeout in ms (default: 30000)
- idleTimeout - idle connection timeout in ms
- maxLifetime - maximum connection lifetime in ms
-
dataSource
Sets an external DataSource to use instead of creating one.This is useful when you want to manage the connection pool yourself or use a different connection pool implementation.
-
local
Creates a builder configured for a local PostgreSQL instance.- Parameters:
database- the database nameusername- the usernamepassword- the password- Returns:
- a pre-configured builder
-
build
Builds the PostgresPlugin.- Throws:
IllegalStateException- if required configuration is missing
-