brain/brain.go
2023-07-04 10:08:43 +08:00

29 lines
572 B
Go

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 {
cnf Config
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
}