mirror of
https://github.com/go-micro/go-micro.git
synced 2025-06-24 22:26:54 +02:00
Add cache example (#2232)
This commit is contained in:
31
examples/cache/main.go
vendored
Normal file
31
examples/cache/main.go
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/asim/go-micro/examples/v3/cache/handler"
|
||||
pb "github.com/asim/go-micro/examples/v3/cache/proto"
|
||||
|
||||
"github.com/asim/go-micro/v3"
|
||||
log "github.com/asim/go-micro/v3/logger"
|
||||
)
|
||||
|
||||
var (
|
||||
service = "go.micro.srv.cache"
|
||||
version = "latest"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create service
|
||||
srv := micro.NewService(
|
||||
micro.Name(service),
|
||||
micro.Version(version),
|
||||
)
|
||||
srv.Init()
|
||||
|
||||
// Register handler
|
||||
pb.RegisterCacheHandler(srv.Server(), handler.NewCache())
|
||||
|
||||
// Run service
|
||||
if err := srv.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user