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 (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 }