-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic UI for PeerDB (only connectors page is wired) (#377)
- This brings the various UI elements to our lib - Also wires up the gRPC from FE to BE. - Connectors page is wired, but lots of other work left. - Serves as a prototype for other pages.
- Loading branch information
1 parent
40a454a
commit c1d153a
Showing
234 changed files
with
25,961 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package utils | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/PeerDB-io/peer-flow/connectors/utils" | ||
"github.com/PeerDB-io/peer-flow/generated/protos" | ||
"github.com/jackc/pgx/v5/pgxpool" | ||
) | ||
|
||
func GetCatalogConnectionPoolFromEnv() (*pgxpool.Pool, error) { | ||
catalogConnectionString, err := genCatalogConnectionString() | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to generate catalog connection string: %w", err) | ||
} | ||
|
||
catalogConn, err := pgxpool.New(context.Background(), catalogConnectionString) | ||
if err != nil { | ||
return nil, fmt.Errorf("unable to establish connection with catalog: %w", err) | ||
} | ||
|
||
return catalogConn, nil | ||
} | ||
|
||
func genCatalogConnectionString() (string, error) { | ||
host, ok := os.LookupEnv("PEERDB_CATALOG_HOST") | ||
if !ok { | ||
return "", fmt.Errorf("PEERDB_CATALOG_HOST is not set") | ||
} | ||
portStr, ok := os.LookupEnv("PEERDB_CATALOG_PORT") | ||
if !ok { | ||
return "", fmt.Errorf("PEERDB_CATALOG_PORT is not set") | ||
} | ||
port, err := strconv.ParseUint(portStr, 10, 32) | ||
if err != nil { | ||
return "", fmt.Errorf("unable to parse PEERDB_CATALOG_PORT as unsigned integer") | ||
} | ||
user, ok := os.LookupEnv("PEERDB_CATALOG_USER") | ||
if !ok { | ||
return "", fmt.Errorf("PEERDB_CATALOG_USER is not set") | ||
} | ||
password, ok := os.LookupEnv("PEERDB_CATALOG_PASSWORD") | ||
if !ok { | ||
return "", fmt.Errorf("PEERDB_CATALOG_PASSWORD is not set") | ||
} | ||
database, ok := os.LookupEnv("PEERDB_CATALOG_DATABASE") | ||
if !ok { | ||
return "", fmt.Errorf("PEERDB_CATALOG_DATABASE is not set") | ||
} | ||
|
||
return utils.GetPGConnectionString(&protos.PostgresConfig{ | ||
Host: host, | ||
Port: uint32(port), | ||
User: user, | ||
Password: password, | ||
Database: database, | ||
}), nil | ||
} |
Oops, something went wrong.