From 5e9f654f732120001381b54bc801986eca1a67b7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Dec 2025 03:37:33 +0000 Subject: [PATCH 1/5] Initial plan From eed8243d885a5b733e0c38c67b8eb2bf91389dff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Dec 2025 03:50:54 +0000 Subject: [PATCH 2/5] chore: rename module paths without hyphens Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com> --- README.md | 16 ++++++++-------- doc.go | 6 +++--- {gorm-client => gormclient}/db.go | 0 {gorm-client => gormclient}/db_test.go | 0 {gorm-client => gormclient}/doc.go | 4 ++-- {gorm-client => gormclient}/example_test.go | 10 +++++----- {grpc-utils => grpcutils}/doc.go | 6 +++--- {grpc-utils => grpcutils}/example_test.go | 2 +- {grpc-utils => grpcutils}/interceptors.go | 0 {kafka-client => kafkaclient}/doc.go | 0 {kafka-client => kafkaclient}/reader.go | 0 {kafka-client => kafkaclient}/reader_test.go | 0 {kafka-client => kafkaclient}/writer.go | 0 {kafka-client => kafkaclient}/writer_test.go | 0 {mongo-client => mongoclient}/client.go | 0 {mongo-client => mongoclient}/doc.go | 4 ++-- {mongo-client => mongoclient}/example_test.go | 12 ++++++------ {object-storage => objectstorage}/client.go | 0 {object-storage => objectstorage}/client_test.go | 0 {object-storage => objectstorage}/doc.go | 4 ++-- .../example_test.go | 2 +- {object-storage => objectstorage}/fileinfo.go | 0 {object-storage => objectstorage}/interface.go | 0 {object-storage => objectstorage}/local.go | 0 {object-storage => objectstorage}/local_test.go | 0 {object-storage => objectstorage}/minio.go | 0 {object-storage => objectstorage}/minio_test.go | 0 {object-storage => objectstorage}/volcengine.go | 0 {redis-client => redisclient}/cache.go | 0 {redis-client => redisclient}/cache_test.go | 2 +- {redis-client => redisclient}/doc.go | 4 ++-- {redis-client => redisclient}/example_test.go | 4 ++-- {redis-client => redisclient}/rdb.go | 0 {redis-client => redisclient}/rdb_test.go | 2 +- {smtp-mailer => smtpmailer}/doc.go | 4 ++-- {smtp-mailer => smtpmailer}/example_test.go | 2 +- {smtp-mailer => smtpmailer}/mailer.go | 0 37 files changed, 42 insertions(+), 42 deletions(-) rename {gorm-client => gormclient}/db.go (100%) rename {gorm-client => gormclient}/db_test.go (100%) rename {gorm-client => gormclient}/doc.go (96%) rename {gorm-client => gormclient}/example_test.go (86%) rename {grpc-utils => grpcutils}/doc.go (96%) rename {grpc-utils => grpcutils}/example_test.go (98%) rename {grpc-utils => grpcutils}/interceptors.go (100%) rename {kafka-client => kafkaclient}/doc.go (100%) rename {kafka-client => kafkaclient}/reader.go (100%) rename {kafka-client => kafkaclient}/reader_test.go (100%) rename {kafka-client => kafkaclient}/writer.go (100%) rename {kafka-client => kafkaclient}/writer_test.go (100%) rename {mongo-client => mongoclient}/client.go (100%) rename {mongo-client => mongoclient}/doc.go (96%) rename {mongo-client => mongoclient}/example_test.go (88%) rename {object-storage => objectstorage}/client.go (100%) rename {object-storage => objectstorage}/client_test.go (100%) rename {object-storage => objectstorage}/doc.go (97%) rename {object-storage => objectstorage}/example_test.go (98%) rename {object-storage => objectstorage}/fileinfo.go (100%) rename {object-storage => objectstorage}/interface.go (100%) rename {object-storage => objectstorage}/local.go (100%) rename {object-storage => objectstorage}/local_test.go (100%) rename {object-storage => objectstorage}/minio.go (100%) rename {object-storage => objectstorage}/minio_test.go (100%) rename {object-storage => objectstorage}/volcengine.go (100%) rename {redis-client => redisclient}/cache.go (100%) rename {redis-client => redisclient}/cache_test.go (98%) rename {redis-client => redisclient}/doc.go (97%) rename {redis-client => redisclient}/example_test.go (97%) rename {redis-client => redisclient}/rdb.go (100%) rename {redis-client => redisclient}/rdb_test.go (98%) rename {smtp-mailer => smtpmailer}/doc.go (98%) rename {smtp-mailer => smtpmailer}/example_test.go (98%) rename {smtp-mailer => smtpmailer}/mailer.go (100%) diff --git a/README.md b/README.md index a7a9996..00ddb1e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ package main import ( "log/slog" "github.com/poly-workshop/go-webmods/app" - "github.com/poly-workshop/go-webmods/gorm_client" + gorm_client "github.com/poly-workshop/go-webmods/gormclient" ) func main() { @@ -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) +### [gorm_client](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) +### [mongo_client](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) +### [redis_client](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) +### [kafka_client](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) +### [object_storage](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) +### [grpc_utils](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) +### [smtp_mailer](https://pkg.go.dev/github.com/poly-workshop/go-webmods/smtpmailer) SMTP email client with: - TLS support - HTML and plain text emails diff --git a/doc.go b/doc.go index 9c09c7e..dac8754 100644 --- a/doc.go +++ b/doc.go @@ -35,7 +35,7 @@ // // 2. Initialize components using their factory functions: // -// import "github.com/poly-workshop/go-webmods/gorm_client" +// import gorm_client "github.com/poly-workshop/go-webmods/gormclient" // // db := gorm_client.NewDB(gorm_client.Config{ // Driver: "postgres", @@ -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" +// gorm_client "github.com/poly-workshop/go-webmods/gormclient" +// redis_client "github.com/poly-workshop/go-webmods/redisclient" // ) // // func main() { diff --git a/gorm-client/db.go b/gormclient/db.go similarity index 100% rename from gorm-client/db.go rename to gormclient/db.go diff --git a/gorm-client/db_test.go b/gormclient/db_test.go similarity index 100% rename from gorm-client/db_test.go rename to gormclient/db_test.go diff --git a/gorm-client/doc.go b/gormclient/doc.go similarity index 96% rename from gorm-client/doc.go rename to gormclient/doc.go index b96bbe8..2a536ee 100644 --- a/gorm-client/doc.go +++ b/gormclient/doc.go @@ -10,7 +10,7 @@ // // Create a PostgreSQL connection: // -// import "github.com/poly-workshop/go-webmods/gorm_client" +// import gorm_client "github.com/poly-workshop/go-webmods/gormclient" // // db := gorm_client.NewDB(gorm_client.Config{ // Driver: "postgres", @@ -37,7 +37,7 @@ // // import ( // "github.com/poly-workshop/go-webmods/app" -// "github.com/poly-workshop/go-webmods/gorm_client" +// gorm_client "github.com/poly-workshop/go-webmods/gormclient" // ) // // func main() { diff --git a/gorm-client/example_test.go b/gormclient/example_test.go similarity index 86% rename from gorm-client/example_test.go rename to gormclient/example_test.go index bc0f8dc..04970f4 100644 --- a/gorm-client/example_test.go +++ b/gormclient/example_test.go @@ -3,12 +3,12 @@ package gorm_client_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 gorm_client "github.com/poly-workshop/go-webmods/gormclient" // // db := gorm_client.NewDB(gorm_client.Config{ // Driver: "postgres", @@ -29,7 +29,7 @@ func Example() { // Example_sqlite demonstrates creating a SQLite database connection. func Example_sqlite() { - // import "github.com/poly-workshop/go-webmods/gorm_client" + // import gorm_client "github.com/poly-workshop/go-webmods/gormclient" // // db := gorm_client.NewDB(gorm_client.Config{ // Driver: "sqlite", @@ -45,7 +45,7 @@ func Example_sqlite() { // Example_mysql demonstrates creating a MySQL database connection. func Example_mysql() { - // import "github.com/poly-workshop/go-webmods/gorm_client" + // import gorm_client "github.com/poly-workshop/go-webmods/gormclient" // // db := gorm_client.NewDB(gorm_client.Config{ // Driver: "mysql", @@ -67,7 +67,7 @@ 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 gorm_client "github.com/poly-workshop/go-webmods/gormclient" // // app.Init(".") // cfg := app.Config() diff --git a/grpc-utils/doc.go b/grpcutils/doc.go similarity index 96% rename from grpc-utils/doc.go rename to grpcutils/doc.go index 5c36732..b95b2e0 100644 --- a/grpc-utils/doc.go +++ b/grpcutils/doc.go @@ -13,7 +13,7 @@ // // import ( // "log/slog" -// "github.com/poly-workshop/go-webmods/grpc_utils" +// grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" // "google.golang.org/grpc" // ) // @@ -55,7 +55,7 @@ // import ( // "log/slog" // "github.com/poly-workshop/go-webmods/app" -// "github.com/poly-workshop/go-webmods/grpc_utils" +// grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" // "google.golang.org/grpc" // ) // @@ -172,7 +172,7 @@ // "net" // "log/slog" // "github.com/poly-workshop/go-webmods/app" -// "github.com/poly-workshop/go-webmods/grpc_utils" +// grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" // "google.golang.org/grpc" // "google.golang.org/grpc/health" // "google.golang.org/grpc/health/grpc_health_v1" diff --git a/grpc-utils/example_test.go b/grpcutils/example_test.go similarity index 98% rename from grpc-utils/example_test.go rename to grpcutils/example_test.go index 7af3605..32611fd 100644 --- a/grpc-utils/example_test.go +++ b/grpcutils/example_test.go @@ -7,7 +7,7 @@ import ( "net" "github.com/poly-workshop/go-webmods/app" - grpc_utils "github.com/poly-workshop/go-webmods/grpc-utils" + grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" "google.golang.org/grpc" ) diff --git a/grpc-utils/interceptors.go b/grpcutils/interceptors.go similarity index 100% rename from grpc-utils/interceptors.go rename to grpcutils/interceptors.go diff --git a/kafka-client/doc.go b/kafkaclient/doc.go similarity index 100% rename from kafka-client/doc.go rename to kafkaclient/doc.go diff --git a/kafka-client/reader.go b/kafkaclient/reader.go similarity index 100% rename from kafka-client/reader.go rename to kafkaclient/reader.go diff --git a/kafka-client/reader_test.go b/kafkaclient/reader_test.go similarity index 100% rename from kafka-client/reader_test.go rename to kafkaclient/reader_test.go diff --git a/kafka-client/writer.go b/kafkaclient/writer.go similarity index 100% rename from kafka-client/writer.go rename to kafkaclient/writer.go diff --git a/kafka-client/writer_test.go b/kafkaclient/writer_test.go similarity index 100% rename from kafka-client/writer_test.go rename to kafkaclient/writer_test.go diff --git a/mongo-client/client.go b/mongoclient/client.go similarity index 100% rename from mongo-client/client.go rename to mongoclient/client.go diff --git a/mongo-client/doc.go b/mongoclient/doc.go similarity index 96% rename from mongo-client/doc.go rename to mongoclient/doc.go index cd18f2e..1da86be 100644 --- a/mongo-client/doc.go +++ b/mongoclient/doc.go @@ -5,7 +5,7 @@ // // Create a MongoDB client (recommended when you need explicit lifecycle management): // -// import "github.com/poly-workshop/go-webmods/mongo_client" +// import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" // // client := mongo_client.NewClient(mongo_client.Config{ // URI: "mongodb://localhost:27017", @@ -31,7 +31,7 @@ // // import ( // "github.com/poly-workshop/go-webmods/app" -// "github.com/poly-workshop/go-webmods/mongo_client" +// mongo_client "github.com/poly-workshop/go-webmods/mongoclient" // ) // // func main() { diff --git a/mongo-client/example_test.go b/mongoclient/example_test.go similarity index 88% rename from mongo-client/example_test.go rename to mongoclient/example_test.go index 2a6d259..fef815e 100644 --- a/mongo-client/example_test.go +++ b/mongoclient/example_test.go @@ -3,12 +3,12 @@ package mongo_client_test import ( "fmt" - _ "github.com/poly-workshop/go-webmods/mongo-client" + _ "github.com/poly-workshop/go-webmods/mongoclient" ) // Example demonstrates creating a MongoDB client connection with explicit lifecycle management. func Example() { - // import "github.com/poly-workshop/go-webmods/mongo_client" + // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" // import "context" // // client := mongo_client.NewClient(mongo_client.Config{ @@ -27,7 +27,7 @@ func Example() { // Example_database demonstrates creating a MongoDB database for long-running applications. func Example_database() { - // import "github.com/poly-workshop/go-webmods/mongo_client" + // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" // // // For long-running applications (servers, daemons) // db := mongo_client.NewDatabase(mongo_client.Config{ @@ -44,7 +44,7 @@ func Example_database() { // Example_atlas demonstrates connecting to MongoDB Atlas. func Example_atlas() { - // import "github.com/poly-workshop/go-webmods/mongo_client" + // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" // import "time" // // client := mongo_client.NewClient(mongo_client.Config{ @@ -66,7 +66,7 @@ func Example_atlas() { 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/mongo_client" + // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" // // app.Init(".") // cfg := app.Config() @@ -92,7 +92,7 @@ func Example_withConfig() { // Example_operations demonstrates basic MongoDB operations. func Example_operations() { - // import "github.com/poly-workshop/go-webmods/mongo_client" + // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" // import "context" // import "go.mongodb.org/mongo-driver/v2/bson" // diff --git a/object-storage/client.go b/objectstorage/client.go similarity index 100% rename from object-storage/client.go rename to objectstorage/client.go diff --git a/object-storage/client_test.go b/objectstorage/client_test.go similarity index 100% rename from object-storage/client_test.go rename to objectstorage/client_test.go diff --git a/object-storage/doc.go b/objectstorage/doc.go similarity index 97% rename from object-storage/doc.go rename to objectstorage/doc.go index aade29d..22a586e 100644 --- a/object-storage/doc.go +++ b/objectstorage/doc.go @@ -11,7 +11,7 @@ // // Create a storage client: // -// import "github.com/poly-workshop/go-webmods/object_storage" +// import object_storage "github.com/poly-workshop/go-webmods/objectstorage" // // storage, err := object_storage.NewObjectStorage(object_storage.Config{ // ProviderType: object_storage.ProviderLocal, @@ -146,7 +146,7 @@ // // import ( // "github.com/poly-workshop/go-webmods/app" -// "github.com/poly-workshop/go-webmods/object_storage" +// object_storage "github.com/poly-workshop/go-webmods/objectstorage" // ) // // app.Init(".") diff --git a/object-storage/example_test.go b/objectstorage/example_test.go similarity index 98% rename from object-storage/example_test.go rename to objectstorage/example_test.go index 50ff29b..c31c686 100644 --- a/object-storage/example_test.go +++ b/objectstorage/example_test.go @@ -5,7 +5,7 @@ import ( "fmt" "io" - object_storage "github.com/poly-workshop/go-webmods/object-storage" + object_storage "github.com/poly-workshop/go-webmods/objectstorage" ) // Example demonstrates basic object storage usage with the local provider. diff --git a/object-storage/fileinfo.go b/objectstorage/fileinfo.go similarity index 100% rename from object-storage/fileinfo.go rename to objectstorage/fileinfo.go diff --git a/object-storage/interface.go b/objectstorage/interface.go similarity index 100% rename from object-storage/interface.go rename to objectstorage/interface.go diff --git a/object-storage/local.go b/objectstorage/local.go similarity index 100% rename from object-storage/local.go rename to objectstorage/local.go diff --git a/object-storage/local_test.go b/objectstorage/local_test.go similarity index 100% rename from object-storage/local_test.go rename to objectstorage/local_test.go diff --git a/object-storage/minio.go b/objectstorage/minio.go similarity index 100% rename from object-storage/minio.go rename to objectstorage/minio.go diff --git a/object-storage/minio_test.go b/objectstorage/minio_test.go similarity index 100% rename from object-storage/minio_test.go rename to objectstorage/minio_test.go diff --git a/object-storage/volcengine.go b/objectstorage/volcengine.go similarity index 100% rename from object-storage/volcengine.go rename to objectstorage/volcengine.go diff --git a/redis-client/cache.go b/redisclient/cache.go similarity index 100% rename from redis-client/cache.go rename to redisclient/cache.go diff --git a/redis-client/cache_test.go b/redisclient/cache_test.go similarity index 98% rename from redis-client/cache_test.go rename to redisclient/cache_test.go index da3b0af..bcfcfb2 100644 --- a/redis-client/cache_test.go +++ b/redisclient/cache_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - redis_client "github.com/poly-workshop/go-webmods/redis-client" + redis_client "github.com/poly-workshop/go-webmods/redisclient" ) func TestNewCache(t *testing.T) { diff --git a/redis-client/doc.go b/redisclient/doc.go similarity index 97% rename from redis-client/doc.go rename to redisclient/doc.go index fd5703e..13354a4 100644 --- a/redis-client/doc.go +++ b/redisclient/doc.go @@ -6,7 +6,7 @@ // // Create Redis clients using the factory pattern to support multiple independent clients: // -// import "github.com/poly-workshop/go-webmods/redis_client" +// import redis_client "github.com/poly-workshop/go-webmods/redisclient" // // func main() { // // Create a Redis client @@ -63,7 +63,7 @@ // // Factory pattern cache creation (recommended): // -// import "github.com/poly-workshop/go-webmods/redis_client" +// import redis_client "github.com/poly-workshop/go-webmods/redisclient" // // func main() { // rdb := redis_client.NewRDB(redis_client.Config{ diff --git a/redis-client/example_test.go b/redisclient/example_test.go similarity index 97% rename from redis-client/example_test.go rename to redisclient/example_test.go index 9a34975..a8bfa74 100644 --- a/redis-client/example_test.go +++ b/redisclient/example_test.go @@ -3,7 +3,7 @@ package redis_client_test import ( "fmt" - _ "github.com/poly-workshop/go-webmods/redis-client" + _ "github.com/poly-workshop/go-webmods/redisclient" ) // Example demonstrates basic Redis client usage. @@ -36,7 +36,7 @@ func Example() { // Example_cluster demonstrates Redis cluster configuration. func Example_cluster() { - // import "github.com/poly-workshop/go-webmods/redis_client" + // import redis_client "github.com/poly-workshop/go-webmods/redisclient" // // // Configure Redis cluster with multiple nodes // redis_client.SetConfig( diff --git a/redis-client/rdb.go b/redisclient/rdb.go similarity index 100% rename from redis-client/rdb.go rename to redisclient/rdb.go diff --git a/redis-client/rdb_test.go b/redisclient/rdb_test.go similarity index 98% rename from redis-client/rdb_test.go rename to redisclient/rdb_test.go index b910c2a..ae8a309 100644 --- a/redis-client/rdb_test.go +++ b/redisclient/rdb_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - redis_client "github.com/poly-workshop/go-webmods/redis-client" + redis_client "github.com/poly-workshop/go-webmods/redisclient" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) diff --git a/smtp-mailer/doc.go b/smtpmailer/doc.go similarity index 98% rename from smtp-mailer/doc.go rename to smtpmailer/doc.go index 7cb0e64..9f6d30a 100644 --- a/smtp-mailer/doc.go +++ b/smtpmailer/doc.go @@ -5,7 +5,7 @@ // // Create a mailer and send an email: // -// import "github.com/poly-workshop/go-webmods/smtp_mailer" +// import smtp_mailer "github.com/poly-workshop/go-webmods/smtpmailer" // // mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ // Host: "smtp.gmail.com", @@ -110,7 +110,7 @@ // // import ( // "github.com/poly-workshop/go-webmods/app" -// "github.com/poly-workshop/go-webmods/smtp_mailer" +// "github.com/poly-workshop/go-webmods/smtpmailer" // ) // // app.Init(".") diff --git a/smtp-mailer/example_test.go b/smtpmailer/example_test.go similarity index 98% rename from smtp-mailer/example_test.go rename to smtpmailer/example_test.go index 8358d60..8c8c36d 100644 --- a/smtp-mailer/example_test.go +++ b/smtpmailer/example_test.go @@ -3,7 +3,7 @@ package smtp_mailer_test import ( "fmt" - smtp_mailer "github.com/poly-workshop/go-webmods/smtp-mailer" + smtp_mailer "github.com/poly-workshop/go-webmods/smtpmailer" ) // Example demonstrates basic email sending. diff --git a/smtp-mailer/mailer.go b/smtpmailer/mailer.go similarity index 100% rename from smtp-mailer/mailer.go rename to smtpmailer/mailer.go From 33b2770762f6ffbdc222bee18e31eac7a0d7a29b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Dec 2025 03:51:54 +0000 Subject: [PATCH 3/5] fix: correct grpcutils app import path Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com> --- grpcutils/interceptors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grpcutils/interceptors.go b/grpcutils/interceptors.go index 631613b..5c942da 100644 --- a/grpcutils/interceptors.go +++ b/grpcutils/interceptors.go @@ -6,7 +6,7 @@ import ( "github.com/google/uuid" "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" - "github.com/oj-lab/go-webmods/app" + "github.com/poly-workshop/go-webmods/app" "google.golang.org/grpc" "google.golang.org/grpc/metadata" ) From a8289725d161efffa817337f082ea79ae3f70924 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Dec 2025 03:53:59 +0000 Subject: [PATCH 4/5] Rename modules to hyphenless paths and update references Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com> --- go.mod | 1 - go.sum | 2 -- 2 files changed, 3 deletions(-) diff --git a/go.mod b/go.mod index f1feb0c..76f3d66 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 7f08176..e287d7e 100644 --- a/go.sum +++ b/go.sum @@ -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= From e0824b85cecbae686adfe5b478269c5d46dab259 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 21 Dec 2025 04:49:15 +0000 Subject: [PATCH 5/5] refactor: drop package aliases to match hyphenless names Co-authored-by: slhmy <31381093+slhmy@users.noreply.github.com> --- README.md | 24 ++++++++-------- doc.go | 32 ++++++++++----------- gormclient/db.go | 2 +- gormclient/db_test.go | 2 +- gormclient/doc.go | 16 +++++------ gormclient/example_test.go | 18 ++++++------ grpcutils/doc.go | 22 +++++++------- grpcutils/example_test.go | 12 ++++---- grpcutils/interceptors.go | 2 +- kafkaclient/doc.go | 8 +++--- kafkaclient/reader.go | 6 ++-- kafkaclient/reader_test.go | 2 +- kafkaclient/writer.go | 6 ++-- kafkaclient/writer_test.go | 2 +- mongoclient/client.go | 2 +- mongoclient/doc.go | 16 +++++------ mongoclient/example_test.go | 22 +++++++------- objectstorage/client.go | 2 +- objectstorage/client_test.go | 2 +- objectstorage/doc.go | 54 +++++++++++++++++------------------ objectstorage/example_test.go | 34 +++++++++++----------- objectstorage/fileinfo.go | 2 +- objectstorage/interface.go | 2 +- objectstorage/local.go | 2 +- objectstorage/local_test.go | 2 +- objectstorage/minio.go | 2 +- objectstorage/minio_test.go | 2 +- objectstorage/volcengine.go | 2 +- redisclient/cache.go | 8 +++--- redisclient/cache_test.go | 22 +++++++------- redisclient/doc.go | 42 +++++++++++++-------------- redisclient/example_test.go | 34 +++++++++++----------- redisclient/rdb.go | 6 ++-- redisclient/rdb_test.go | 18 ++++++------ smtpmailer/doc.go | 24 ++++++++-------- smtpmailer/example_test.go | 22 +++++++------- smtpmailer/mailer.go | 2 +- 37 files changed, 239 insertions(+), 239 deletions(-) diff --git a/README.md b/README.md index 00ddb1e..3b1e41d 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ package main import ( "log/slog" "github.com/poly-workshop/go-webmods/app" - gorm_client "github.com/poly-workshop/go-webmods/gormclient" + gormclient "github.com/poly-workshop/go-webmods/gormclient" ) func main() { @@ -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, @@ -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/gormclient) +### [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/mongoclient) +### [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/redisclient) +### [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/kafkaclient) +### [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/objectstorage) +### [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/grpcutils) +### [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/smtpmailer) +### [smtpmailer](https://pkg.go.dev/github.com/poly-workshop/go-webmods/smtpmailer) SMTP email client with: - TLS support - HTML and plain text emails @@ -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", }, }) diff --git a/doc.go b/doc.go index dac8754..508a081 100644 --- a/doc.go +++ b/doc.go @@ -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 // @@ -35,9 +35,9 @@ // // 2. Initialize components using their factory functions: // -// import gorm_client "github.com/poly-workshop/go-webmods/gormclient" +// 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, @@ -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", // }, // }) @@ -87,8 +87,8 @@ // import ( // "log/slog" // "github.com/poly-workshop/go-webmods/app" -// gorm_client "github.com/poly-workshop/go-webmods/gormclient" -// redis_client "github.com/poly-workshop/go-webmods/redisclient" +// gormclient "github.com/poly-workshop/go-webmods/gormclient" +// redisclient "github.com/poly-workshop/go-webmods/redisclient" // ) // // func main() { @@ -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 diff --git a/gormclient/db.go b/gormclient/db.go index daa7b7f..b1bb03a 100644 --- a/gormclient/db.go +++ b/gormclient/db.go @@ -1,4 +1,4 @@ -package gorm_client +package gormclient import ( "fmt" diff --git a/gormclient/db_test.go b/gormclient/db_test.go index 812435f..2ab5131 100644 --- a/gormclient/db_test.go +++ b/gormclient/db_test.go @@ -1,4 +1,4 @@ -package gorm_client +package gormclient import ( "os" diff --git a/gormclient/doc.go b/gormclient/doc.go index 2a536ee..c583325 100644 --- a/gormclient/doc.go +++ b/gormclient/doc.go @@ -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 @@ -10,9 +10,9 @@ // // Create a PostgreSQL connection: // -// import gorm_client "github.com/poly-workshop/go-webmods/gormclient" +// 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, @@ -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 // }) @@ -37,13 +37,13 @@ // // import ( // "github.com/poly-workshop/go-webmods/app" -// gorm_client "github.com/poly-workshop/go-webmods/gormclient" +// 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"), @@ -53,7 +53,7 @@ // SSLMode: app.Config().GetString("database.sslmode"), // } // -// db := gorm_client.NewDB(cfg) +// db := gormclient.NewDB(cfg) // // Use db for GORM operations // } // @@ -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 diff --git a/gormclient/example_test.go b/gormclient/example_test.go index 04970f4..e43d02b 100644 --- a/gormclient/example_test.go +++ b/gormclient/example_test.go @@ -1,4 +1,4 @@ -package gorm_client_test +package gormclient_test import ( "fmt" @@ -8,9 +8,9 @@ import ( // Example demonstrates creating a PostgreSQL database connection. func Example() { - // import gorm_client "github.com/poly-workshop/go-webmods/gormclient" + // 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, @@ -29,9 +29,9 @@ func Example() { // Example_sqlite demonstrates creating a SQLite database connection. func Example_sqlite() { - // import gorm_client "github.com/poly-workshop/go-webmods/gormclient" + // 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", // }) @@ -45,9 +45,9 @@ func Example_sqlite() { // Example_mysql demonstrates creating a MySQL database connection. func Example_mysql() { - // import gorm_client "github.com/poly-workshop/go-webmods/gormclient" + // 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, @@ -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 gorm_client "github.com/poly-workshop/go-webmods/gormclient" + // 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"), diff --git a/grpcutils/doc.go b/grpcutils/doc.go index b95b2e0..b9ba8da 100644 --- a/grpcutils/doc.go +++ b/grpcutils/doc.go @@ -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 @@ -13,14 +13,14 @@ // // import ( // "log/slog" -// grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" +// 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), // ), // ) // @@ -36,7 +36,7 @@ // // server := grpc.NewServer( // grpc.ChainUnaryInterceptor( -// grpc_utils.BuildRequestIDInterceptor(), +// grpcutils.BuildRequestIDInterceptor(), // ), // ) // @@ -55,7 +55,7 @@ // import ( // "log/slog" // "github.com/poly-workshop/go-webmods/app" -// grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" +// grpcutils "github.com/poly-workshop/go-webmods/grpcutils" // "google.golang.org/grpc" // ) // @@ -66,8 +66,8 @@ // logger := slog.Default() // server := grpc.NewServer( // grpc.ChainUnaryInterceptor( -// grpc_utils.BuildRequestIDInterceptor(), -// grpc_utils.BuildLogInterceptor(logger), +// grpcutils.BuildRequestIDInterceptor(), +// grpcutils.BuildLogInterceptor(logger), // ), // ) // @@ -172,7 +172,7 @@ // "net" // "log/slog" // "github.com/poly-workshop/go-webmods/app" -// grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" +// 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" @@ -191,8 +191,8 @@ // logger := slog.Default() // server := grpc.NewServer( // grpc.ChainUnaryInterceptor( -// grpc_utils.BuildRequestIDInterceptor(), -// grpc_utils.BuildLogInterceptor(logger), +// grpcutils.BuildRequestIDInterceptor(), +// grpcutils.BuildLogInterceptor(logger), // ), // ) // @@ -212,4 +212,4 @@ // panic(err) // } // } -package grpc_utils +package grpcutils diff --git a/grpcutils/example_test.go b/grpcutils/example_test.go index 32611fd..2b60a9b 100644 --- a/grpcutils/example_test.go +++ b/grpcutils/example_test.go @@ -1,4 +1,4 @@ -package grpc_utils_test +package grpcutils_test import ( "context" @@ -7,7 +7,7 @@ import ( "net" "github.com/poly-workshop/go-webmods/app" - grpc_utils "github.com/poly-workshop/go-webmods/grpcutils" + grpcutils "github.com/poly-workshop/go-webmods/grpcutils" "google.golang.org/grpc" ) @@ -22,8 +22,8 @@ func Example() { // Create gRPC server with interceptors server := grpc.NewServer( grpc.ChainUnaryInterceptor( - grpc_utils.BuildRequestIDInterceptor(), - grpc_utils.BuildLogInterceptor(logger), + grpcutils.BuildRequestIDInterceptor(), + grpcutils.BuildLogInterceptor(logger), ), ) @@ -97,8 +97,8 @@ func Example_fullServer() { // logger := slog.Default() // server := grpc.NewServer( // grpc.ChainUnaryInterceptor( - // grpc_utils.BuildRequestIDInterceptor(), - // grpc_utils.BuildLogInterceptor(logger), + // grpcutils.BuildRequestIDInterceptor(), + // grpcutils.BuildLogInterceptor(logger), // ), // ) diff --git a/grpcutils/interceptors.go b/grpcutils/interceptors.go index 5c942da..0fd7d9b 100644 --- a/grpcutils/interceptors.go +++ b/grpcutils/interceptors.go @@ -1,4 +1,4 @@ -package grpc_utils +package grpcutils import ( "context" diff --git a/kafkaclient/doc.go b/kafkaclient/doc.go index 30d4983..23b02d4 100644 --- a/kafkaclient/doc.go +++ b/kafkaclient/doc.go @@ -1,9 +1,9 @@ -// Package kafka_client provides factory functions for creating Kafka readers +// Package kafkaclient provides factory functions for creating Kafka readers // and writers using github.com/segmentio/kafka-go. // // # Reader // -// reader := kafka_client.NewReader(kafka_client.ReaderConfig{ +// reader := kafkaclient.NewReader(kafkaclient.ReaderConfig{ // Brokers: []string{"localhost:9092"}, // Topic: "example-topic", // GroupID: "example-group", @@ -12,9 +12,9 @@ // // # Writer // -// writer := kafka_client.NewWriter(kafka_client.WriterConfig{ +// writer := kafkaclient.NewWriter(kafkaclient.WriterConfig{ // Brokers: []string{"localhost:9092"}, // Topic: "example-topic", // }) // defer writer.Close() -package kafka_client +package kafkaclient diff --git a/kafkaclient/reader.go b/kafkaclient/reader.go index be36e49..0533bf3 100644 --- a/kafkaclient/reader.go +++ b/kafkaclient/reader.go @@ -1,4 +1,4 @@ -package kafka_client +package kafkaclient import ( "github.com/segmentio/kafka-go" @@ -16,10 +16,10 @@ type ReaderConfig struct { func NewReader(cfg ReaderConfig) *kafka.Reader { if len(cfg.Brokers) == 0 { - panic("kafka_client: no kafka brokers configured") + panic("kafkaclient: no kafka brokers configured") } if cfg.Topic == "" { - panic("kafka_client: topic is required") + panic("kafkaclient: topic is required") } readerCfg := kafka.ReaderConfig{ diff --git a/kafkaclient/reader_test.go b/kafkaclient/reader_test.go index 763fc81..c9b24dd 100644 --- a/kafkaclient/reader_test.go +++ b/kafkaclient/reader_test.go @@ -1,4 +1,4 @@ -package kafka_client +package kafkaclient import ( "testing" diff --git a/kafkaclient/writer.go b/kafkaclient/writer.go index a719565..82de497 100644 --- a/kafkaclient/writer.go +++ b/kafkaclient/writer.go @@ -1,4 +1,4 @@ -package kafka_client +package kafkaclient import ( "time" @@ -21,10 +21,10 @@ type WriterConfig struct { func NewWriter(cfg WriterConfig) *kafka.Writer { if len(cfg.Brokers) == 0 { - panic("kafka_client: no kafka brokers configured") + panic("kafkaclient: no kafka brokers configured") } if cfg.Topic == "" { - panic("kafka_client: topic is required") + panic("kafkaclient: topic is required") } writerCfg := kafka.WriterConfig{ diff --git a/kafkaclient/writer_test.go b/kafkaclient/writer_test.go index 7f06e28..173a1df 100644 --- a/kafkaclient/writer_test.go +++ b/kafkaclient/writer_test.go @@ -1,4 +1,4 @@ -package kafka_client +package kafkaclient import ( "testing" diff --git a/mongoclient/client.go b/mongoclient/client.go index 304bc5f..a802c0f 100644 --- a/mongoclient/client.go +++ b/mongoclient/client.go @@ -1,4 +1,4 @@ -package mongo_client +package mongoclient import ( "context" diff --git a/mongoclient/doc.go b/mongoclient/doc.go index 1da86be..5835ff0 100644 --- a/mongoclient/doc.go +++ b/mongoclient/doc.go @@ -1,13 +1,13 @@ -// Package mongo_client provides a factory function for creating MongoDB +// Package mongoclient provides a factory function for creating MongoDB // connections using the MongoDB Go Driver v2. // // # Basic Usage // // Create a MongoDB client (recommended when you need explicit lifecycle management): // -// import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" +// import mongoclient "github.com/poly-workshop/go-webmods/mongoclient" // -// client := mongo_client.NewClient(mongo_client.Config{ +// client := mongoclient.NewClient(mongoclient.Config{ // URI: "mongodb://localhost:27017", // Database: "mydb", // }) @@ -18,7 +18,7 @@ // // Create a MongoDB database directly (for long-running applications): // -// db := mongo_client.NewDatabase(mongo_client.Config{ +// db := mongoclient.NewDatabase(mongoclient.Config{ // URI: "mongodb://localhost:27017", // Database: "mydb", // }) @@ -31,20 +31,20 @@ // // import ( // "github.com/poly-workshop/go-webmods/app" -// mongo_client "github.com/poly-workshop/go-webmods/mongoclient" +// mongoclient "github.com/poly-workshop/go-webmods/mongoclient" // ) // // func main() { // app.Init(".") // -// cfg := mongo_client.Config{ +// cfg := mongoclient.Config{ // URI: app.Config().GetString("mongodb.uri"), // Database: app.Config().GetString("mongodb.database"), // ConnectTimeout: app.Config().GetDuration("mongodb.connect_timeout"), // PingTimeout: app.Config().GetDuration("mongodb.ping_timeout"), // } // -// db := mongo_client.NewDatabase(cfg) +// db := mongoclient.NewDatabase(cfg) // // Use db for MongoDB operations // } // @@ -144,4 +144,4 @@ // - Enable authentication and TLS for production connections // - Use indexes to optimize query performance // - Monitor connection pool metrics in production -package mongo_client +package mongoclient diff --git a/mongoclient/example_test.go b/mongoclient/example_test.go index fef815e..66ff6c2 100644 --- a/mongoclient/example_test.go +++ b/mongoclient/example_test.go @@ -1,4 +1,4 @@ -package mongo_client_test +package mongoclient_test import ( "fmt" @@ -8,10 +8,10 @@ import ( // Example demonstrates creating a MongoDB client connection with explicit lifecycle management. func Example() { - // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" + // import mongoclient "github.com/poly-workshop/go-webmods/mongoclient" // import "context" // - // client := mongo_client.NewClient(mongo_client.Config{ + // client := mongoclient.NewClient(mongoclient.Config{ // URI: "mongodb://localhost:27017", // Database: "mydb", // }) @@ -27,10 +27,10 @@ func Example() { // Example_database demonstrates creating a MongoDB database for long-running applications. func Example_database() { - // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" + // import mongoclient "github.com/poly-workshop/go-webmods/mongoclient" // // // For long-running applications (servers, daemons) - // db := mongo_client.NewDatabase(mongo_client.Config{ + // db := mongoclient.NewDatabase(mongoclient.Config{ // URI: "mongodb://localhost:27017", // Database: "mydb", // }) @@ -44,10 +44,10 @@ func Example_database() { // Example_atlas demonstrates connecting to MongoDB Atlas. func Example_atlas() { - // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" + // import mongoclient "github.com/poly-workshop/go-webmods/mongoclient" // import "time" // - // client := mongo_client.NewClient(mongo_client.Config{ + // client := mongoclient.NewClient(mongoclient.Config{ // URI: "mongodb+srv://username:password@cluster.mongodb.net/", // Database: "production", // ConnectTimeout: 15 * time.Second, @@ -66,12 +66,12 @@ func Example_atlas() { func Example_withConfig() { // In a real application, you would load these from app.Config() // import "github.com/poly-workshop/go-webmods/app" - // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" + // import mongoclient "github.com/poly-workshop/go-webmods/mongoclient" // // app.Init(".") // cfg := app.Config() // - // db := mongo_client.NewDatabase(mongo_client.Config{ + // db := mongoclient.NewDatabase(mongoclient.Config{ // URI: cfg.GetString("mongodb.uri"), // Database: cfg.GetString("mongodb.database"), // ConnectTimeout: cfg.GetDuration("mongodb.connect_timeout"), @@ -92,11 +92,11 @@ func Example_withConfig() { // Example_operations demonstrates basic MongoDB operations. func Example_operations() { - // import mongo_client "github.com/poly-workshop/go-webmods/mongoclient" + // import mongoclient "github.com/poly-workshop/go-webmods/mongoclient" // import "context" // import "go.mongodb.org/mongo-driver/v2/bson" // - // db := mongo_client.NewDatabase(mongo_client.Config{ + // db := mongoclient.NewDatabase(mongoclient.Config{ // URI: "mongodb://localhost:27017", // Database: "mydb", // }) diff --git a/objectstorage/client.go b/objectstorage/client.go index 6e0fd01..c3ab5bc 100644 --- a/objectstorage/client.go +++ b/objectstorage/client.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import "fmt" diff --git a/objectstorage/client_test.go b/objectstorage/client_test.go index aedcb61..77ae0d0 100644 --- a/objectstorage/client_test.go +++ b/objectstorage/client_test.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "os" diff --git a/objectstorage/doc.go b/objectstorage/doc.go index 22a586e..915986b 100644 --- a/objectstorage/doc.go +++ b/objectstorage/doc.go @@ -1,4 +1,4 @@ -// Package object_storage provides a unified interface for object storage across +// Package objectstorage provides a unified interface for object storage across // multiple providers including local filesystem, MinIO, and Volcengine TOS. // // # Supported Providers @@ -11,11 +11,11 @@ // // Create a storage client: // -// import object_storage "github.com/poly-workshop/go-webmods/objectstorage" +// import objectstorage "github.com/poly-workshop/go-webmods/objectstorage" // -// 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/uploads", // }, // }) @@ -27,9 +27,9 @@ // // Store files on the local filesystem: // -// 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: "/var/data", // Base directory for all files // }, // }) @@ -38,9 +38,9 @@ // // Connect to MinIO or any S3-compatible service: // -// storage, err := object_storage.NewObjectStorage(object_storage.Config{ -// ProviderType: object_storage.ProviderMinio, -// ProviderConfig: object_storage.ProviderConfig{ +// storage, err := objectstorage.NewObjectStorage(objectstorage.Config{ +// ProviderType: objectstorage.ProviderMinio, +// ProviderConfig: objectstorage.ProviderConfig{ // Endpoint: "minio.example.com:9000", // Region: "us-east-1", // AccessKey: "minioadmin", @@ -54,9 +54,9 @@ // // Connect to Volcengine TOS: // -// storage, err := object_storage.NewObjectStorage(object_storage.Config{ -// ProviderType: object_storage.ProviderVolcengine, -// ProviderConfig: object_storage.ProviderConfig{ +// storage, err := objectstorage.NewObjectStorage(objectstorage.Config{ +// ProviderType: objectstorage.ProviderVolcengine, +// ProviderConfig: objectstorage.ProviderConfig{ // Endpoint: "tos-cn-beijing.volces.com", // Region: "cn-beijing", // AccessKey: "your-access-key", @@ -128,13 +128,13 @@ // // Example configuration file (configs/default.yaml): // -// object_storage: +// objectstorage: // provider: local // base_path: /var/data/uploads // // For production (configs/production.yaml): // -// object_storage: +// objectstorage: // provider: minio // endpoint: minio.prod.example.com:9000 // region: us-east-1 @@ -146,21 +146,21 @@ // // import ( // "github.com/poly-workshop/go-webmods/app" -// object_storage "github.com/poly-workshop/go-webmods/objectstorage" +// objectstorage "github.com/poly-workshop/go-webmods/objectstorage" // ) // // app.Init(".") // cfg := app.Config() // -// storage, err := object_storage.NewObjectStorage(object_storage.Config{ -// ProviderType: object_storage.ProviderType(cfg.GetString("object_storage.provider")), -// ProviderConfig: object_storage.ProviderConfig{ -// Endpoint: cfg.GetString("object_storage.endpoint"), -// Region: cfg.GetString("object_storage.region"), -// AccessKey: cfg.GetString("object_storage.access_key"), -// SecretKey: cfg.GetString("object_storage.secret_key"), -// Bucket: cfg.GetString("object_storage.bucket"), -// BasePath: cfg.GetString("object_storage.base_path"), +// storage, err := objectstorage.NewObjectStorage(objectstorage.Config{ +// ProviderType: objectstorage.ProviderType(cfg.GetString("objectstorage.provider")), +// ProviderConfig: objectstorage.ProviderConfig{ +// Endpoint: cfg.GetString("objectstorage.endpoint"), +// Region: cfg.GetString("objectstorage.region"), +// AccessKey: cfg.GetString("objectstorage.access_key"), +// SecretKey: cfg.GetString("objectstorage.secret_key"), +// Bucket: cfg.GetString("objectstorage.bucket"), +// BasePath: cfg.GetString("objectstorage.base_path"), // }, // }) // @@ -211,4 +211,4 @@ // - UseInternal=true uses internal endpoint (for in-region VMs) // - Supports Volcengine-specific features // - Region must match bucket region -package object_storage +package objectstorage diff --git a/objectstorage/example_test.go b/objectstorage/example_test.go index c31c686..a2fbf68 100644 --- a/objectstorage/example_test.go +++ b/objectstorage/example_test.go @@ -1,18 +1,18 @@ -package object_storage_test +package objectstorage_test import ( "bytes" "fmt" "io" - object_storage "github.com/poly-workshop/go-webmods/objectstorage" + objectstorage "github.com/poly-workshop/go-webmods/objectstorage" ) // Example demonstrates basic object storage usage with the local provider. func Example() { - 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: "/tmp/storage", }, }) @@ -50,9 +50,9 @@ func Example() { // Example_minio demonstrates using MinIO or S3-compatible storage. func Example_minio() { - storage, err := object_storage.NewObjectStorage(object_storage.Config{ - ProviderType: object_storage.ProviderMinio, - ProviderConfig: object_storage.ProviderConfig{ + storage, err := objectstorage.NewObjectStorage(objectstorage.Config{ + ProviderType: objectstorage.ProviderMinio, + ProviderConfig: objectstorage.ProviderConfig{ Endpoint: "minio.example.com:9000", Region: "us-east-1", AccessKey: "minioadmin", @@ -72,9 +72,9 @@ func Example_minio() { // Example_list demonstrates listing objects in a directory. func Example_list() { - 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: "/tmp/storage", }, }) @@ -101,9 +101,9 @@ func Example_list() { // Example_stat demonstrates getting file metadata without downloading. func Example_stat() { - 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: "/tmp/storage", }, }) @@ -127,9 +127,9 @@ func Example_stat() { // Example_delete demonstrates deleting a file from storage. func Example_delete() { - 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: "/tmp/storage", }, }) diff --git a/objectstorage/fileinfo.go b/objectstorage/fileinfo.go index 4c4ae61..9ef3eac 100644 --- a/objectstorage/fileinfo.go +++ b/objectstorage/fileinfo.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "os" diff --git a/objectstorage/interface.go b/objectstorage/interface.go index 88c4884..d7a4dea 100644 --- a/objectstorage/interface.go +++ b/objectstorage/interface.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "io" diff --git a/objectstorage/local.go b/objectstorage/local.go index 7de8e96..b8b3297 100644 --- a/objectstorage/local.go +++ b/objectstorage/local.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "io" diff --git a/objectstorage/local_test.go b/objectstorage/local_test.go index 25a3331..0a326bf 100644 --- a/objectstorage/local_test.go +++ b/objectstorage/local_test.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "io" diff --git a/objectstorage/minio.go b/objectstorage/minio.go index 8acb30a..8a4f287 100644 --- a/objectstorage/minio.go +++ b/objectstorage/minio.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "context" diff --git a/objectstorage/minio_test.go b/objectstorage/minio_test.go index e42cbfd..756f1cc 100644 --- a/objectstorage/minio_test.go +++ b/objectstorage/minio_test.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "testing" diff --git a/objectstorage/volcengine.go b/objectstorage/volcengine.go index 25db262..d0bcdc4 100644 --- a/objectstorage/volcengine.go +++ b/objectstorage/volcengine.go @@ -1,4 +1,4 @@ -package object_storage +package objectstorage import ( "context" diff --git a/redisclient/cache.go b/redisclient/cache.go index 44ba720..c108777 100644 --- a/redisclient/cache.go +++ b/redisclient/cache.go @@ -1,4 +1,4 @@ -package redis_client +package redisclient import ( "context" @@ -47,16 +47,16 @@ type CacheConfig struct { // // Example: // -// rdb := redis_client.NewRDB(redis_client.Config{ +// rdb := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"localhost:6379"}, // Password: "", // }) -// cache := redis_client.NewCache(redis_client.CacheConfig{ +// cache := redisclient.NewCache(redisclient.CacheConfig{ // Redis: rdb, // }) func NewCache(cfg CacheConfig) *Cache { if cfg.Redis == nil { - panic("redis_client: Redis client is required for cache") + panic("redisclient: Redis client is required for cache") } // Set defaults diff --git a/redisclient/cache_test.go b/redisclient/cache_test.go index bcfcfb2..ca3d570 100644 --- a/redisclient/cache_test.go +++ b/redisclient/cache_test.go @@ -1,11 +1,11 @@ -package redis_client_test +package redisclient_test import ( "context" "testing" "time" - redis_client "github.com/poly-workshop/go-webmods/redisclient" + redisclient "github.com/poly-workshop/go-webmods/redisclient" ) func TestNewCache(t *testing.T) { @@ -13,12 +13,12 @@ func TestNewCache(t *testing.T) { defer cleanup() t.Run("BasicCacheOperations", func(t *testing.T) { - rdb := redis_client.NewRDB(redis_client.Config{ + rdb := redisclient.NewRDB(redisclient.Config{ Urls: []string{addr}, Password: "", }) - cache := redis_client.NewCache(redis_client.CacheConfig{ + cache := redisclient.NewCache(redisclient.CacheConfig{ Redis: rdb, }) @@ -61,22 +61,22 @@ func TestNewCache(t *testing.T) { }) t.Run("MultipleCacheInstances", func(t *testing.T) { - rdb1 := redis_client.NewRDB(redis_client.Config{ + rdb1 := redisclient.NewRDB(redisclient.Config{ Urls: []string{addr}, Password: "", }) - rdb2 := redis_client.NewRDB(redis_client.Config{ + rdb2 := redisclient.NewRDB(redisclient.Config{ Urls: []string{addr}, Password: "", }) - cache1 := redis_client.NewCache(redis_client.CacheConfig{ + cache1 := redisclient.NewCache(redisclient.CacheConfig{ Redis: rdb1, RefreshEventChannel: "cache1:refresh", }) - cache2 := redis_client.NewCache(redis_client.CacheConfig{ + cache2 := redisclient.NewCache(redisclient.CacheConfig{ Redis: rdb2, RefreshEventChannel: "cache2:refresh", }) @@ -119,12 +119,12 @@ func TestNewCache(t *testing.T) { }) t.Run("CustomConfiguration", func(t *testing.T) { - rdb := redis_client.NewRDB(redis_client.Config{ + rdb := redisclient.NewRDB(redisclient.Config{ Urls: []string{addr}, Password: "", }) - cache := redis_client.NewCache(redis_client.CacheConfig{ + cache := redisclient.NewCache(redisclient.CacheConfig{ Redis: rdb, RefreshEventChannel: "custom:channel", LocalCacheSize: 500, @@ -158,7 +158,7 @@ func TestNewCache(t *testing.T) { } }() - redis_client.NewCache(redis_client.CacheConfig{ + redisclient.NewCache(redisclient.CacheConfig{ Redis: nil, }) }) diff --git a/redisclient/doc.go b/redisclient/doc.go index 13354a4..1893d43 100644 --- a/redisclient/doc.go +++ b/redisclient/doc.go @@ -1,4 +1,4 @@ -// Package redis_client provides Redis client factories with support for both +// Package redisclient provides Redis client factories with support for both // single-node and cluster modes, plus an integrated caching layer with local // memory cache and distributed cache invalidation. // @@ -6,11 +6,11 @@ // // Create Redis clients using the factory pattern to support multiple independent clients: // -// import redis_client "github.com/poly-workshop/go-webmods/redisclient" +// import redisclient "github.com/poly-workshop/go-webmods/redisclient" // // func main() { // // Create a Redis client -// rdb := redis_client.NewRDB(redis_client.Config{ +// rdb := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"localhost:6379"}, // Password: "", // }) @@ -23,12 +23,12 @@ // // The factory pattern allows creating multiple independent Redis clients: // -// primaryRDB := redis_client.NewRDB(redis_client.Config{ +// primaryRDB := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"primary:6379"}, // Password: "secret1", // }) // -// cacheRDB := redis_client.NewRDB(redis_client.Config{ +// cacheRDB := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"cache:6379"}, // Password: "secret2", // }) @@ -39,7 +39,7 @@ // // Redis Cluster example: // -// rdb := redis_client.NewRDB(redis_client.Config{ +// rdb := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"node1:6379", "node2:6379", "node3:6379"}, // Password: "password", // }) @@ -48,8 +48,8 @@ // // The legacy singleton pattern is still supported for backward compatibility: // -// redis_client.SetConfig([]string{"localhost:6379"}, "") -// rdb := redis_client.GetRDB() +// redisclient.SetConfig([]string{"localhost:6379"}, "") +// rdb := redisclient.GetRDB() // // However, this pattern is deprecated. Use NewRDB instead for better control // and to support multiple clients. @@ -63,15 +63,15 @@ // // Factory pattern cache creation (recommended): // -// import redis_client "github.com/poly-workshop/go-webmods/redisclient" +// import redisclient "github.com/poly-workshop/go-webmods/redisclient" // // func main() { -// rdb := redis_client.NewRDB(redis_client.Config{ +// rdb := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"localhost:6379"}, // Password: "", // }) // -// cache := redis_client.NewCache(redis_client.CacheConfig{ +// cache := redisclient.NewCache(redisclient.CacheConfig{ // Redis: rdb, // RefreshEventChannel: "myapp:cache:refresh", // LocalCacheSize: 2000, @@ -96,25 +96,25 @@ // // Singleton pattern cache creation (deprecated): // -// redis_client.SetConfig([]string{"localhost:6379"}, "") -// cache := redis_client.GetCache() +// redisclient.SetConfig([]string{"localhost:6379"}, "") +// cache := redisclient.GetCache() // // # Multiple Cache Instances // // The factory pattern allows creating multiple independent cache instances: // -// primaryRDB := redis_client.NewRDB(redis_client.Config{ +// primaryRDB := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"primary:6379"}, // }) -// sessionRDB := redis_client.NewRDB(redis_client.Config{ +// sessionRDB := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"session:6379"}, // }) // -// primaryCache := redis_client.NewCache(redis_client.CacheConfig{ +// primaryCache := redisclient.NewCache(redisclient.CacheConfig{ // Redis: primaryRDB, // RefreshEventChannel: "primary:refresh", // }) -// sessionCache := redis_client.NewCache(redis_client.CacheConfig{ +// sessionCache := redisclient.NewCache(redisclient.CacheConfig{ // Redis: sessionRDB, // RefreshEventChannel: "session:refresh", // }) @@ -130,8 +130,8 @@ // // Customize the cache refresh channel name (must be done before GetCache): // -// redis_client.SetCacheRefreshEventChannel("myapp:cache:refresh") -// cache := redis_client.GetCache() +// redisclient.SetCacheRefreshEventChannel("myapp:cache:refresh") +// cache := redisclient.GetCache() // // # Singleton Pattern (Deprecated) // @@ -190,7 +190,7 @@ // import "github.com/poly-workshop/go-webmods/app" // // app.Init(".") -// redis_client.SetConfig( +// redisclient.SetConfig( // app.Config().GetStringSlice("redis.urls"), // app.Config().GetString("redis.password"), // ) @@ -218,4 +218,4 @@ // // Handle cache miss or error // // Load from database, etc. // } -package redis_client +package redisclient diff --git a/redisclient/example_test.go b/redisclient/example_test.go index a8bfa74..e64d294 100644 --- a/redisclient/example_test.go +++ b/redisclient/example_test.go @@ -1,4 +1,4 @@ -package redis_client_test +package redisclient_test import ( "fmt" @@ -9,10 +9,10 @@ import ( // Example demonstrates basic Redis client usage. func Example() { // Configure Redis connection - // redis_client.SetConfig([]string{"localhost:6379"}, "") + // redisclient.SetConfig([]string{"localhost:6379"}, "") // // // Get Redis client - // rdb := redis_client.GetRDB() + // rdb := redisclient.GetRDB() // // ctx := context.Background() // @@ -36,10 +36,10 @@ func Example() { // Example_cluster demonstrates Redis cluster configuration. func Example_cluster() { - // import redis_client "github.com/poly-workshop/go-webmods/redisclient" + // import redisclient "github.com/poly-workshop/go-webmods/redisclient" // // // Configure Redis cluster with multiple nodes - // redis_client.SetConfig( + // redisclient.SetConfig( // []string{ // "node1.redis.example.com:6379", // "node2.redis.example.com:6379", @@ -49,7 +49,7 @@ func Example_cluster() { // ) // // // Get Redis client (automatically uses cluster mode) - // rdb := redis_client.GetRDB() + // rdb := redisclient.GetRDB() // _ = rdb fmt.Println("Redis cluster configured") @@ -59,10 +59,10 @@ func Example_cluster() { // Example_cache demonstrates using the cache layer with local and distributed caching. func Example_cache() { // Configure Redis - // redis_client.SetConfig([]string{"localhost:6379"}, "") + // redisclient.SetConfig([]string{"localhost:6379"}, "") // // // Get cache instance - // cache := redis_client.GetCache() + // cache := redisclient.GetCache() // // ctx := context.Background() // @@ -98,13 +98,13 @@ func Example_cache() { // Example_cacheInvalidation demonstrates cache invalidation across multiple instances. func Example_cacheInvalidation() { // Configure Redis - // redis_client.SetConfig([]string{"localhost:6379"}, "") + // redisclient.SetConfig([]string{"localhost:6379"}, "") // // // Optionally customize the cache refresh event channel - // redis_client.SetCacheRefreshEventChannel("myapp:cache:refresh") + // redisclient.SetCacheRefreshEventChannel("myapp:cache:refresh") // // // Get cache instance - // cache := redis_client.GetCache() + // cache := redisclient.GetCache() // // ctx := context.Background() // @@ -122,12 +122,12 @@ func Example_cacheInvalidation() { // Example_newRDB demonstrates creating multiple independent Redis clients. func Example_newRDB() { // Create multiple Redis clients with different configurations - // rdb1 := redis_client.NewRDB(redis_client.Config{ + // rdb1 := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"localhost:6379"}, // Password: "", // }) // - // rdb2 := redis_client.NewRDB(redis_client.Config{ + // rdb2 := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"redis-cluster:6379"}, // Password: "secret", // }) @@ -150,25 +150,25 @@ func Example_newRDB() { // Example_newCache demonstrates creating multiple cache instances with different Redis backends. func Example_newCache() { // Create Redis clients for different purposes - // primaryRDB := redis_client.NewRDB(redis_client.Config{ + // primaryRDB := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"primary-redis:6379"}, // Password: "", // }) // - // sessionRDB := redis_client.NewRDB(redis_client.Config{ + // sessionRDB := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"session-redis:6379"}, // Password: "", // }) // // // Create separate cache instances - // primaryCache := redis_client.NewCache(redis_client.CacheConfig{ + // primaryCache := redisclient.NewCache(redisclient.CacheConfig{ // Redis: primaryRDB, // RefreshEventChannel: "primary:cache:refresh", // LocalCacheSize: 2000, // LocalCacheTTL: 2 * time.Minute, // }) // - // sessionCache := redis_client.NewCache(redis_client.CacheConfig{ + // sessionCache := redisclient.NewCache(redisclient.CacheConfig{ // Redis: sessionRDB, // RefreshEventChannel: "session:cache:refresh", // LocalCacheSize: 1000, diff --git a/redisclient/rdb.go b/redisclient/rdb.go index 848bcd8..a99c921 100644 --- a/redisclient/rdb.go +++ b/redisclient/rdb.go @@ -1,4 +1,4 @@ -package redis_client +package redisclient import ( "sync" @@ -26,13 +26,13 @@ var ( // // Example: // -// rdb := redis_client.NewRDB(redis_client.Config{ +// rdb := redisclient.NewRDB(redisclient.Config{ // Urls: []string{"localhost:6379"}, // Password: "", // }) func NewRDB(cfg Config) redis.UniversalClient { if len(cfg.Urls) == 0 { - panic("redis_client: no redis hosts configured") + panic("redisclient: no redis hosts configured") } if len(cfg.Urls) == 1 { return redis.NewClient(&redis.Options{ diff --git a/redisclient/rdb_test.go b/redisclient/rdb_test.go index ae8a309..47e57b1 100644 --- a/redisclient/rdb_test.go +++ b/redisclient/rdb_test.go @@ -1,11 +1,11 @@ -package redis_client_test +package redisclient_test import ( "context" "testing" "time" - redis_client "github.com/poly-workshop/go-webmods/redisclient" + redisclient "github.com/poly-workshop/go-webmods/redisclient" "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" ) @@ -56,7 +56,7 @@ func TestNewRDB(t *testing.T) { // Test creating a single-node client t.Run("SingleNode", func(t *testing.T) { - rdb := redis_client.NewRDB(redis_client.Config{ + rdb := redisclient.NewRDB(redisclient.Config{ Urls: []string{addr}, Password: "", }) @@ -82,12 +82,12 @@ func TestNewRDB(t *testing.T) { // Test creating multiple independent clients t.Run("MultipleClients", func(t *testing.T) { - rdb1 := redis_client.NewRDB(redis_client.Config{ + rdb1 := redisclient.NewRDB(redisclient.Config{ Urls: []string{addr}, Password: "", }) - rdb2 := redis_client.NewRDB(redis_client.Config{ + rdb2 := redisclient.NewRDB(redisclient.Config{ Urls: []string{addr}, Password: "", }) @@ -134,7 +134,7 @@ func TestNewRDB(t *testing.T) { } }() - redis_client.NewRDB(redis_client.Config{ + redisclient.NewRDB(redisclient.Config{ Urls: []string{}, Password: "", }) @@ -146,8 +146,8 @@ func TestGetRDB_BackwardCompatibility(t *testing.T) { defer cleanup() // Test backward compatibility with singleton pattern - redis_client.SetConfig([]string{addr}, "") - rdb := redis_client.GetRDB() + redisclient.SetConfig([]string{addr}, "") + rdb := redisclient.GetRDB() ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() @@ -167,7 +167,7 @@ func TestGetRDB_BackwardCompatibility(t *testing.T) { } // Test that subsequent calls return the same instance - rdb2 := redis_client.GetRDB() + rdb2 := redisclient.GetRDB() if rdb != rdb2 { t.Error("GetRDB should return the same singleton instance") } diff --git a/smtpmailer/doc.go b/smtpmailer/doc.go index 9f6d30a..9bb577f 100644 --- a/smtpmailer/doc.go +++ b/smtpmailer/doc.go @@ -1,13 +1,13 @@ -// Package smtp_mailer provides a simple SMTP email client with TLS support +// Package smtpmailer provides a simple SMTP email client with TLS support // for sending HTML and plain text emails. // // # Basic Usage // // Create a mailer and send an email: // -// import smtp_mailer "github.com/poly-workshop/go-webmods/smtpmailer" +// import smtpmailer "github.com/poly-workshop/go-webmods/smtpmailer" // -// mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ +// mailer := smtpmailer.NewMailer(smtpmailer.Config{ // Host: "smtp.gmail.com", // Port: 587, // Username: "your-email@gmail.com", @@ -16,7 +16,7 @@ // FromName: "My Application", // }) // -// err := mailer.SendEmail(smtp_mailer.Message{ +// err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{"user@example.com"}, // Subject: "Welcome to our service", // Body: "Thank you for signing up!", @@ -27,7 +27,7 @@ // // Send HTML-formatted emails: // -// err := mailer.SendEmail(smtp_mailer.Message{ +// err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{"user@example.com"}, // Subject: "Welcome!", // Body: ` @@ -46,7 +46,7 @@ // // Send to multiple recipients: // -// err := mailer.SendEmail(smtp_mailer.Message{ +// err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{ // "user1@example.com", // "user2@example.com", @@ -116,7 +116,7 @@ // app.Init(".") // cfg := app.Config() // -// mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ +// mailer := smtpmailer.NewMailer(smtpmailer.Config{ // Host: cfg.GetString("smtp.host"), // Port: cfg.GetInt("smtp.port"), // Username: cfg.GetString("smtp.username"), @@ -159,7 +159,7 @@ // return err // } // -// err = mailer.SendEmail(smtp_mailer.Message{ +// err = mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{"alice@example.com"}, // Subject: "Verify your email", // Body: body.String(), @@ -204,7 +204,7 @@ // import "time" // // for _, recipient := range recipients { -// err := mailer.SendEmail(smtp_mailer.Message{ +// err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{recipient}, // Subject: "Newsletter", // Body: content, @@ -229,7 +229,7 @@ // // # Example: Password Reset Email // -// func sendPasswordReset(mailer *smtp_mailer.Mailer, email, token string) error { +// func sendPasswordReset(mailer *smtpmailer.Mailer, email, token string) error { // resetURL := fmt.Sprintf("https://example.com/reset?token=%s", token) // // body := fmt.Sprintf(` @@ -246,11 +246,11 @@ // // `, resetURL) // -// return mailer.SendEmail(smtp_mailer.Message{ +// return mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{email}, // Subject: "Password Reset Request", // Body: body, // IsHTML: true, // }) // } -package smtp_mailer +package smtpmailer diff --git a/smtpmailer/example_test.go b/smtpmailer/example_test.go index 8c8c36d..6a112be 100644 --- a/smtpmailer/example_test.go +++ b/smtpmailer/example_test.go @@ -1,14 +1,14 @@ -package smtp_mailer_test +package smtpmailer_test import ( "fmt" - smtp_mailer "github.com/poly-workshop/go-webmods/smtpmailer" + smtpmailer "github.com/poly-workshop/go-webmods/smtpmailer" ) // Example demonstrates basic email sending. func Example() { - // mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ + // mailer := smtpmailer.NewMailer(smtpmailer.Config{ // Host: "smtp.example.com", // Port: 587, // Username: "user@example.com", @@ -17,7 +17,7 @@ func Example() { // FromName: "My Application", // }) // - // err := mailer.SendEmail(smtp_mailer.Message{ + // err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{"recipient@example.com"}, // Subject: "Hello", // Body: "This is a test email.", @@ -35,7 +35,7 @@ func Example() { // Example_html demonstrates sending HTML emails. func Example_html() { - // mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ + // mailer := smtpmailer.NewMailer(smtpmailer.Config{ // Host: "smtp.example.com", // Port: 587, // Username: "user@example.com", @@ -54,7 +54,7 @@ func Example_html() { // // ` // - // err := mailer.SendEmail(smtp_mailer.Message{ + // err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{"user@example.com"}, // Subject: "Welcome to Our Service", // Body: htmlBody, @@ -72,7 +72,7 @@ func Example_html() { // Example_multipleRecipients demonstrates sending to multiple recipients. func Example_multipleRecipients() { - // mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ + // mailer := smtpmailer.NewMailer(smtpmailer.Config{ // Host: "smtp.example.com", // Port: 587, // Username: "user@example.com", @@ -81,7 +81,7 @@ func Example_multipleRecipients() { // FromName: "Newsletter", // }) // - // err := mailer.SendEmail(smtp_mailer.Message{ + // err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{ // "user1@example.com", // "user2@example.com", @@ -106,7 +106,7 @@ func Example_gmail() { // Note: For Gmail, you need to use an App Password // Go to Google Account > Security > 2-Step Verification > App Passwords - mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ + mailer := smtpmailer.NewMailer(smtpmailer.Config{ Host: "smtp.gmail.com", Port: 587, Username: "your-email@gmail.com", @@ -122,7 +122,7 @@ func Example_gmail() { // Example_passwordReset demonstrates a password reset email. func Example_passwordReset() { - // mailer := smtp_mailer.NewMailer(smtp_mailer.Config{ + // mailer := smtpmailer.NewMailer(smtpmailer.Config{ // Host: "smtp.example.com", // Port: 587, // Username: "user@example.com", @@ -148,7 +148,7 @@ func Example_passwordReset() { // // `, resetURL) // - // err := mailer.SendEmail(smtp_mailer.Message{ + // err := mailer.SendEmail(smtpmailer.Message{ // ToEmails: []string{"user@example.com"}, // Subject: "Password Reset Request", // Body: htmlBody, diff --git a/smtpmailer/mailer.go b/smtpmailer/mailer.go index 8acf83b..5ae5b42 100644 --- a/smtpmailer/mailer.go +++ b/smtpmailer/mailer.go @@ -1,4 +1,4 @@ -package smtp_mailer +package smtpmailer import ( "crypto/tls"