Skip to content

Commit

Permalink
Merge pull request #2839 from dzhwinter/fix_service
Browse files Browse the repository at this point in the history
"fix init error"
  • Loading branch information
QiJune committed Jul 13, 2017
2 parents e6e2bf4 + 7cfcda5 commit b6d2b02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go/cmd/pserver/pserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {

var idx int

var cp *pserver.Checkpoint
var cp pserver.Checkpoint
var e *pserver.EtcdClient
if *index >= 0 {
idx = *index
Expand Down
8 changes: 4 additions & 4 deletions go/pserver/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type parameterCheckpoint struct {
}

// NewCheckpointFromFile loads parameters and state from checkpoint file
func NewCheckpointFromFile(cpPath string, idx int, e *EtcdClient) (*Checkpoint, error) {
func NewCheckpointFromFile(cpPath string, idx int, e *EtcdClient) (Checkpoint, error) {
v, err := e.GetKey(PsPath+string(idx), 3*time.Second)
if err != nil {
return nil, err
Expand All @@ -110,7 +110,7 @@ func NewCheckpointFromFile(cpPath string, idx int, e *EtcdClient) (*Checkpoint,
}

dec := gob.NewDecoder(bytes.NewReader(content))
cp := &Checkpoint{}
cp := Checkpoint{}
if err = dec.Decode(cp); err != nil {
return nil, err
}
Expand All @@ -119,7 +119,7 @@ func NewCheckpointFromFile(cpPath string, idx int, e *EtcdClient) (*Checkpoint,

// NewService creates a new service, will bypass etcd registration if no
// endpoints specified. It will recovery from checkpoint file if a exists a specified checkpoint.
func NewService(idx int, interval time.Duration, path string, client *EtcdClient, cp *Checkpoint) (*Service, error) {
func NewService(idx int, interval time.Duration, path string, client *EtcdClient, cp Checkpoint) (*Service, error) {
s := &Service{
idx: idx,
checkpointInterval: interval,
Expand All @@ -130,7 +130,7 @@ func NewService(idx int, interval time.Duration, path string, client *EtcdClient
s.initialized = make(chan struct{})

if cp != nil {
for _, item := range *cp {
for _, item := range cp {
p := ParameterWithConfig{
Param: item.Param,
Config: item.Config,
Expand Down

0 comments on commit b6d2b02

Please sign in to comment.