01cloud-notification is a Go-based gRPC service for publishing, storing, querying, and managing notification and activity-log events across distributed systems.
- gRPC API for notification lifecycle operations (
Publish,Post,Query,Update,Delete,MarkAll) - Activity log APIs (
StoreActivityLog,GetActivityLog) - Email dispatch support via SMTP
- Pluggable message brokers:
- Google Pub/Sub (default)
- RabbitMQ
- Pluggable storage backends:
- Firestore (default)
- MongoDB
- Go 1.22+
- Protobuf compiler (
protoc) if you regenerate gRPC stubs - Access to one message backend (Pub/Sub or RabbitMQ)
- Access to one store backend (Firestore or MongoDB)
-
Clone the repository.
-
Copy the sample environment file:
cp .env.sample .env
-
Update
.envwith your environment values. -
Install dependencies and start:
go mod download go run .
The server starts on 0.0.0.0:$GRPC_SERVER_PORT.
pre-commit install
pre-commit run --all-files
go test ./...Use the proto definition from proto/notification/notification.proto in your client service.
package main
import (
"context"
"time"
pb "github.com/berrybytes/01cloud-notification/proto/notification"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func main() {
conn, _ := grpc.Dial("localhost:10080", grpc.WithTransportCredentials(insecure.NewCredentials()))
defer conn.Close()
client := pb.NewNotificationClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, _ = client.Post(ctx, &pb.PostRequest{
Message: &pb.Message{
Type: "info",
Body: "hello from client",
SendBy: "example-client",
User: 1,
},
})
}The service is configured through environment variables.
| Variable | Required | Description |
|---|---|---|
GRPC_SERVER_PORT |
Yes | gRPC server port |
STORE_TYPE |
No | firestore (default) or mongo |
MESSAGE_TYPE |
No | pubsub (default) or rabbitmq |
GCLOUD_PROJECT |
Required for Pub/Sub/Firestore | Google Cloud project ID |
GCLOUD_NAMESPACE |
Required for Pub/Sub/Firestore | Prefix for topics/collections |
MONGO_URL |
Required for MongoDB | MongoDB connection string |
MONGO_DB |
Required for MongoDB | MongoDB database name |
RABBITMQ_URL |
Required for RabbitMQ | AMQP connection URL |
WS_SERVER |
Optional | WebSocket server base URL |
WS_SECRET |
Optional | Token used when sending websocket notifications |
DB_URL |
Optional | SQL connection format used by controller logic |
SMTP_HOST |
Optional | SMTP host |
SMTP_PORT |
Optional | SMTP port |
SMTP_USERNAME |
Optional | SMTP username |
SMTP_PASSWORD |
Optional | SMTP password |
SMTP_FROM_ADDRESS |
Optional | Sender address |
HOST_URL |
Optional | Product/app URL used in email templates |
PRODUCT_LOGO |
Optional | Logo URL used in email templates |
See .env.sample for a template.
Contributions are welcome. Please read CONTRIBUTING.md before opening issues or pull requests.
Please report vulnerabilities privately as described in SECURITY.md.
This project is currently licensed under Apache 2.0. See LICENSE.