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
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package main
import (
"log/slog"
"github.com/poly-workshop/go-webmods/app"
"github.com/poly-workshop/go-webmods/gorm_client"
gormclient "github.com/poly-workshop/go-webmods/gormclient"
)

func main() {
Expand All @@ -35,7 +35,7 @@ func main() {
app.Init(".") // Loads config from ./configs/

// Initialize database
db := gorm_client.NewDB(gorm_client.Config{
db := gormclient.NewDB(gormclient.Config{
Driver: "postgres",
Host: "localhost",
Port: 5432,
Expand All @@ -58,43 +58,43 @@ Core application utilities including:
- Structured logging with context propagation (slog)
- Application initialization helpers

### [gorm_client](https://pkg.go.dev/github.com/poly-workshop/go-webmods/gorm_client)
### [gormclient](https://pkg.go.dev/github.com/poly-workshop/go-webmods/gormclient)
Database client factory supporting:
- PostgreSQL
- MySQL
- SQLite
- Connection pooling configuration

### [mongo_client](https://pkg.go.dev/github.com/poly-workshop/go-webmods/mongo_client)
### [mongoclient](https://pkg.go.dev/github.com/poly-workshop/go-webmods/mongoclient)
MongoDB client factory using the v2 driver:
- MongoDB Atlas support
- Connection pooling and timeouts
- Ping verification on startup

### [redis_client](https://pkg.go.dev/github.com/poly-workshop/go-webmods/redis_client)
### [redisclient](https://pkg.go.dev/github.com/poly-workshop/go-webmods/redisclient)
Redis client with:
- Single-node and cluster mode support
- Two-level caching (local + distributed)
- Automatic cache invalidation via pub/sub

### [kafka_client](https://pkg.go.dev/github.com/poly-workshop/go-webmods/kafka_client)
### [kafkaclient](https://pkg.go.dev/github.com/poly-workshop/go-webmods/kafkaclient)
Kafka client helpers with:
- Reader factory (consumer group or partition)
- Writer factory with configurable batching and acknowledgements

### [object_storage](https://pkg.go.dev/github.com/poly-workshop/go-webmods/object_storage)
### [objectstorage](https://pkg.go.dev/github.com/poly-workshop/go-webmods/objectstorage)
Unified object storage interface supporting:
- Local filesystem
- MinIO / S3-compatible storage
- Volcengine TOS

### [grpc_utils](https://pkg.go.dev/github.com/poly-workshop/go-webmods/grpc_utils)
### [grpcutils](https://pkg.go.dev/github.com/poly-workshop/go-webmods/grpcutils)
gRPC server interceptors for:
- Structured logging
- Request ID generation and propagation
- Context-aware tracing

### [smtp_mailer](https://pkg.go.dev/github.com/poly-workshop/go-webmods/smtp_mailer)
### [smtpmailer](https://pkg.go.dev/github.com/poly-workshop/go-webmods/smtpmailer)
SMTP email client with:
- TLS support
- HTML and plain text emails
Expand All @@ -111,9 +111,9 @@ component := package.NewComponent(package.Config{...})
### Provider Pattern
Multi-backend support with unified interfaces:
```go
storage, err := object_storage.NewObjectStorage(object_storage.Config{
ProviderType: object_storage.ProviderLocal,
ProviderConfig: object_storage.ProviderConfig{
storage, err := objectstorage.NewObjectStorage(objectstorage.Config{
ProviderType: objectstorage.ProviderLocal,
ProviderConfig: objectstorage.ProviderConfig{
BasePath: "/data",
},
})
Expand Down
32 changes: 16 additions & 16 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// This library includes the following packages:
//
// - app: Core application utilities for configuration, logging, and context management
// - gorm_client: Database client factory supporting PostgreSQL and SQLite
// - redis_client: Redis client with caching support and cluster mode
// - kafka_client: Kafka client factories for readers and writers
// - object_storage: Multi-provider object storage interface (local, MinIO, Volcengine TOS)
// - grpc_utils: gRPC middleware and interceptors for logging and request ID tracking
// - smtp_mailer: SMTP email sender with TLS support
// - gormclient: Database client factory supporting PostgreSQL and SQLite
// - redisclient: Redis client with caching support and cluster mode
// - kafkaclient: Kafka client factories for readers and writers
// - objectstorage: Multi-provider object storage interface (local, MinIO, Volcengine TOS)
// - grpcutils: gRPC middleware and interceptors for logging and request ID tracking
// - smtpmailer: SMTP email sender with TLS support
//
// # Installation
//
Expand All @@ -35,9 +35,9 @@
//
// 2. Initialize components using their factory functions:
//
// import "github.com/poly-workshop/go-webmods/gorm_client"
// import gormclient "github.com/poly-workshop/go-webmods/gormclient"
//
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: "postgres",
// Host: "localhost",
// Port: 5432,
Expand Down Expand Up @@ -66,9 +66,9 @@
//
// Provider Pattern: Multi-backend support (e.g., object storage):
//
// storage, err := object_storage.NewObjectStorage(object_storage.Config{
// ProviderType: object_storage.ProviderLocal,
// ProviderConfig: object_storage.ProviderConfig{
// storage, err := objectstorage.NewObjectStorage(objectstorage.Config{
// ProviderType: objectstorage.ProviderLocal,
// ProviderConfig: objectstorage.ProviderConfig{
// BasePath: "/data",
// },
// })
Expand All @@ -87,8 +87,8 @@
// import (
// "log/slog"
// "github.com/poly-workshop/go-webmods/app"
// "github.com/poly-workshop/go-webmods/gorm_client"
// "github.com/poly-workshop/go-webmods/redis_client"
// gormclient "github.com/poly-workshop/go-webmods/gormclient"
// redisclient "github.com/poly-workshop/go-webmods/redisclient"
// )
//
// func main() {
Expand All @@ -97,14 +97,14 @@
// app.Init(".")
//
// // Initialize database
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: "sqlite",
// Name: "data/app.db",
// })
//
// // Initialize Redis
// redis_client.SetConfig([]string{"localhost:6379"}, "")
// rdb := redis_client.GetRDB()
// redisclient.SetConfig([]string{"localhost:6379"}, "")
// rdb := redisclient.GetRDB()
//
// slog.Info("Application started successfully")
// // ... rest of application logic
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/google/uuid v1.6.0
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2
github.com/lmittmann/tint v1.1.2
github.com/oj-lab/go-webmods v0.1.4
github.com/redis/go-redis/v9 v9.12.1
github.com/segmentio/kafka-go v0.4.48
github.com/spf13/viper v1.20.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7P
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/oj-lab/go-webmods v0.1.4 h1:NJPv6FxG3JPjwMpUThGtr1ngfkLxVk2cin29MTGuQRA=
github.com/oj-lab/go-webmods v0.1.4/go.mod h1:0XgDlF0OggU8dWTet19gMaUlsmLMVPCMN61ykxQtWWY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
Expand Down
2 changes: 1 addition & 1 deletion gorm-client/db.go → gormclient/db.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gorm_client
package gormclient

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion gorm-client/db_test.go → gormclient/db_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gorm_client
package gormclient

import (
"os"
Expand Down
16 changes: 8 additions & 8 deletions gorm-client/doc.go → gormclient/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package gorm_client provides a factory function for creating GORM database
// Package gormclient provides a factory function for creating GORM database
// connections with support for multiple database drivers.
//
// # Supported Databases
Expand All @@ -10,9 +10,9 @@
//
// Create a PostgreSQL connection:
//
// import "github.com/poly-workshop/go-webmods/gorm_client"
// import gormclient "github.com/poly-workshop/go-webmods/gormclient"
//
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: "postgres",
// Host: "localhost",
// Port: 5432,
Expand All @@ -24,7 +24,7 @@
//
// Create a SQLite connection:
//
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: "sqlite",
// Name: "data/app.db", // File path for SQLite database
// })
Expand All @@ -37,13 +37,13 @@
//
// import (
// "github.com/poly-workshop/go-webmods/app"
// "github.com/poly-workshop/go-webmods/gorm_client"
// gormclient "github.com/poly-workshop/go-webmods/gormclient"
// )
//
// func main() {
// app.Init(".")
//
// cfg := gorm_client.Config{
// cfg := gormclient.Config{
// Driver: app.Config().GetString("database.driver"),
// Host: app.Config().GetString("database.host"),
// Port: app.Config().GetInt("database.port"),
Expand All @@ -53,7 +53,7 @@
// SSLMode: app.Config().GetString("database.sslmode"),
// }
//
// db := gorm_client.NewDB(cfg)
// db := gormclient.NewDB(cfg)
// // Use db for GORM operations
// }
//
Expand Down Expand Up @@ -120,4 +120,4 @@
// - Enable SSL mode for PostgreSQL in production (sslmode: require)
// - Configure connection pooling for high-traffic applications
// - Use migrations for schema management (e.g., golang-migrate or GORM AutoMigrate)
package gorm_client
package gormclient
20 changes: 10 additions & 10 deletions gorm-client/example_test.go → gormclient/example_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package gorm_client_test
package gormclient_test

import (
"fmt"

_ "github.com/poly-workshop/go-webmods/gorm-client"
_ "github.com/poly-workshop/go-webmods/gormclient"
)

// Example demonstrates creating a PostgreSQL database connection.
func Example() {
// import "github.com/poly-workshop/go-webmods/gorm_client"
// import gormclient "github.com/poly-workshop/go-webmods/gormclient"
//
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: "postgres",
// Host: "localhost",
// Port: 5432,
Expand All @@ -29,9 +29,9 @@ func Example() {

// Example_sqlite demonstrates creating a SQLite database connection.
func Example_sqlite() {
// import "github.com/poly-workshop/go-webmods/gorm_client"
// import gormclient "github.com/poly-workshop/go-webmods/gormclient"
//
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: "sqlite",
// Name: "/tmp/test.db",
// })
Expand All @@ -45,9 +45,9 @@ func Example_sqlite() {

// Example_mysql demonstrates creating a MySQL database connection.
func Example_mysql() {
// import "github.com/poly-workshop/go-webmods/gorm_client"
// import gormclient "github.com/poly-workshop/go-webmods/gormclient"
//
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: "mysql",
// Host: "localhost",
// Port: 3306,
Expand All @@ -67,12 +67,12 @@ func Example_mysql() {
func Example_withConfig() {
// In a real application, you would load these from app.Config()
// import "github.com/poly-workshop/go-webmods/app"
// import "github.com/poly-workshop/go-webmods/gorm_client"
// import gormclient "github.com/poly-workshop/go-webmods/gormclient"
//
// app.Init(".")
// cfg := app.Config()
//
// db := gorm_client.NewDB(gorm_client.Config{
// db := gormclient.NewDB(gormclient.Config{
// Driver: cfg.GetString("database.driver"),
// Host: cfg.GetString("database.host"),
// Port: cfg.GetInt("database.port"),
Expand Down
22 changes: 11 additions & 11 deletions grpc-utils/doc.go → grpcutils/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package grpc_utils provides gRPC server interceptors for logging and request
// Package grpcutils provides gRPC server interceptors for logging and request
// ID tracking with context propagation.
//
// # Interceptors
Expand All @@ -13,14 +13,14 @@
//
// import (
// "log/slog"
// "github.com/poly-workshop/go-webmods/grpc_utils"
// grpcutils "github.com/poly-workshop/go-webmods/grpcutils"
// "google.golang.org/grpc"
// )
//
// logger := slog.Default()
// server := grpc.NewServer(
// grpc.ChainUnaryInterceptor(
// grpc_utils.BuildLogInterceptor(logger),
// grpcutils.BuildLogInterceptor(logger),
// ),
// )
//
Expand All @@ -36,7 +36,7 @@
//
// server := grpc.NewServer(
// grpc.ChainUnaryInterceptor(
// grpc_utils.BuildRequestIDInterceptor(),
// grpcutils.BuildRequestIDInterceptor(),
// ),
// )
//
Expand All @@ -55,7 +55,7 @@
// import (
// "log/slog"
// "github.com/poly-workshop/go-webmods/app"
// "github.com/poly-workshop/go-webmods/grpc_utils"
// grpcutils "github.com/poly-workshop/go-webmods/grpcutils"
// "google.golang.org/grpc"
// )
//
Expand All @@ -66,8 +66,8 @@
// logger := slog.Default()
// server := grpc.NewServer(
// grpc.ChainUnaryInterceptor(
// grpc_utils.BuildRequestIDInterceptor(),
// grpc_utils.BuildLogInterceptor(logger),
// grpcutils.BuildRequestIDInterceptor(),
// grpcutils.BuildLogInterceptor(logger),
// ),
// )
//
Expand Down Expand Up @@ -172,7 +172,7 @@
// "net"
// "log/slog"
// "github.com/poly-workshop/go-webmods/app"
// "github.com/poly-workshop/go-webmods/grpc_utils"
// grpcutils "github.com/poly-workshop/go-webmods/grpcutils"
// "google.golang.org/grpc"
// "google.golang.org/grpc/health"
// "google.golang.org/grpc/health/grpc_health_v1"
Expand All @@ -191,8 +191,8 @@
// logger := slog.Default()
// server := grpc.NewServer(
// grpc.ChainUnaryInterceptor(
// grpc_utils.BuildRequestIDInterceptor(),
// grpc_utils.BuildLogInterceptor(logger),
// grpcutils.BuildRequestIDInterceptor(),
// grpcutils.BuildLogInterceptor(logger),
// ),
// )
//
Expand All @@ -212,4 +212,4 @@
// panic(err)
// }
// }
package grpc_utils
package grpcutils
Loading