brain/brain.go

29 lines
572 B
Go
Raw Permalink Normal View History

2023-07-02 16:00:04 +00:00
package brain
import (
context "context"
2023-07-03 02:42:43 +00:00
"log"
"sync/atomic"
2023-07-02 16:00:04 +00:00
"github.com/474420502/brain/pb"
)
// UnimplementedBrainServiceServer can be embedded to have forward compatible implementations.
type BrainService struct {
2023-07-04 02:08:43 +00:00
cnf Config
2023-07-03 02:42:43 +00:00
IsRunningMain atomic.Int64
2023-07-02 16:00:04 +00:00
}
2023-07-03 02:42:43 +00:00
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) {
2023-07-02 16:00:04 +00:00
return &pb.Response{Code: 200}, nil
}