Asjard is a protobuf-driven microservice framework implemented in Go that provides a unified platform for building scalable distributed services. Orchestrates multiple protocols (REST, gRPC, message queues), dynamic configuration management, code generation pipelines, and comprehensive observability features through a single configuration-driven interface.
- Code Generation
- Dynamic Configuration
- Data Stores
- Error Management
- OpenAPI Document
go get -u github.com/asjard/asjard- define protobuf
syntax = "proto3";
package api.v1.example.docs;
// The target Go package path for generated code.
option go_package = "protos-repo/example/api/v1/sample";
import "github.com/asjard/protobuf/http.proto";
import "github.com/asjard/protobuf/validate.proto";
// Sample service provides basic greeting operations.
service Sample {
// SayHello returns a greeting message based on the provided name.
// It supports multiple HTTP GET entrypoints for compatibility and routing flexibility.
rpc SayHello(HelloRequest) returns (HelloReply) {
// Dynamic path mapping (e.g., /helloworld/john)
option (asjard.api.http) = {
get : "/helloworld/{name}"
};
// Static path mapping for general greetings
option (asjard.api.http) = {
get : '/hello'
};
}
}
// HelloRequest defines the input payload for the SayHello method.
message HelloRequest {
// The name of the person to greet.
// Validation: Must be provided (required) and no longer than 20 characters.
string name = 1 [ (asjard.api.validate).rules = "required,max=20" ];
}
// HelloReply defines the output payload containing the greeting result.
message HelloReply {
// The formatted greeting string (e.g., "Hello, name!").
string message = 1;
}- implement in go
package main
import (
"context"
"log"
pb "protos-repo/example/api/v1/sample"
"github.com/asjard/asjard"
"github.com/asjard/asjard/pkg/server/grpc"
"github.com/asjard/asjard/pkg/server/rest"
)
type SampleAPI struct {
pb.UnimplementedSampleServer
}
func NewSampleAPI() *SampleAPI {
return &SampleAPI{}
}
func (api *SampleAPI) Start() error { return nil }
func (api *SampleAPI) Stop() {}
// GRPC server
func (api *SampleAPI) GrpcServiceDesc() *grpc.ServiceDesc { return &pb.Sample_ServiceDesc }
// HTTP server
func (api *SampleAPI) RestServiceDesc() *rest.ServiceDesc { return &pb.SampleRestServiceDesc }
func (api *SampleAPI) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{
Message: "hello " + in.Name,
}, nil
}
func main() {
server := asjard.New()
if err := server.AddHandler(SampleAPI{}, rest.Protocol, grpc.Protocol); err != nil {
log.Fatal(err)
}
log.Fatal(server.Start())
}- Reference Document
- Examples asjard-example
- Study in
- Latency
- Concurrency
- Allocations
More information see TestCode
Here are some open source libraries used in this framework
| Repo | Description |
|---|---|
| fasthttp | http protocol |
| fasthttp-router | http route management |
| grpc | grpc protocol |
| protobuf | protobuf protocol |
| hystrix-go | circuit breaker |
| fsnotify | configration file listen |
| prometheus-client-go | prometheus |
| etcd | etcd client |
| gorm | database client |
| redis | redis client |
| yaml-v2 | yaml parser |
| fressache | local cache |
| gnostic | openapiv3 document generate |
| cast | type convert |
| lumberjack | log |
| asynq | asynq |
| rabbitmq | rabbitmq |





