Go-redis

Making: github.com/golang-coll…

This project is RPC remote call interface of Redis, implemented by GRPC.

The directory structure

- Client client -config-config. go Use Viper to read Consul configuration. -Consul. go Configure Consul constant Operation Encapsulates common redis operations - Pool encapsulates redis connection pool - proto defines proto files - server encapsulates services provided by the server - docker-comemage. yml Docker-compose file used to start the project -dockerfiel Dockerfile used to generate images -main. go Used to generate RPC server-side -makefile Makefile used to execute make commands, Used to format code and generate server-side executable files under LinuxCopy the code

Quick start

git clone [email protected]:golang-collection/Go-redis.git
make
docker network create -d bridge redis_net
cd dependence
docker-compose up -d
Copy the code

The preceding command will start the Redis service and Consul service. Consul can be accessed through localhost:8500. In its key/value, create config and configure as follows

Then go back to the root directory of the project and run the following command to start the GRPC service of Redis.

docker-compose up -d
Copy the code

On the client, you can start the corresponding client to perform operations.

How to generate proto files

go get github.com/golang/protobuf/{proto,protoc-gen-go}
go get github.com/micro/protoc-gen-micro
cd proto
protoc --proto_path=. --micro_out=. --go_out=. redis.proto
Copy the code

Pay attention to

This project encapsulates it as micro-service by go-Micro. However, I think it should not encapsulate it as micro-service for a single Redis, and the division of micro-service should be from the perspective of business.

License

MIT

Copyright (c) 2020 Knowledge-Precipitation-Tribe