Skip to content

Commit

Permalink
leader existence check when calling leader
Browse files Browse the repository at this point in the history
  • Loading branch information
ksrichard committed Dec 3, 2021
1 parent 53a1f9f commit c344fd0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package easyraft

import (
"context"
"errors"
"github.com/ksrichard/easyraft/grpc"
ggrpc "google.golang.org/grpc"
)

func ApplyOnLeader(node *Node, payload []byte) (interface{}, error) {
if node.Raft.Leader() == "" {
return nil, errors.New("unknown leader")
}
var opt ggrpc.DialOption = ggrpc.EmptyDialOption{}
conn, err := ggrpc.Dial(string(node.Raft.Leader()), ggrpc.WithInsecure(), ggrpc.WithBlock(), opt)
if err != nil {
Expand Down

0 comments on commit c344fd0

Please sign in to comment.