thinking 1 level

This commit is contained in:
eson 2023-07-03 10:42:43 +08:00
parent dd81525b9f
commit 6e7f43dfdd
3 changed files with 22 additions and 1 deletions

View File

@ -2,14 +2,26 @@ package brain
import (
context "context"
"log"
"sync/atomic"
"github.com/474420502/brain/pb"
)
// UnimplementedBrainServiceServer can be embedded to have forward compatible implementations.
type BrainService struct {
IsRunningMain atomic.Int64
}
func (*BrainService) Add(context.Context, *pb.Request) (*pb.Response, error) {
func (brain *BrainService) Main() {
if brain.IsRunningMain.CompareAndSwap(0, 1) {
defer brain.IsRunningMain.Swap(0)
} else {
log.Println("Main is Running")
}
}
func (*BrainService) Add(cxt context.Context, req *pb.Request) (*pb.Response, error) {
return &pb.Response{Code: 200}, nil
}

5
config.go Normal file
View File

@ -0,0 +1,5 @@
package brain
// Config 配置
type Config struct {
}

4
state.go Normal file
View File

@ -0,0 +1,4 @@
package brain
type State struct {
}