Ejemplo n.º 1
0
func (fs *FS) Resolve(id int64) error {
	fs.Lock()
	defer fs.Unlock()

	// Read issue file
	unresolved := path.Join(fs.root, "unresolved", issuefs.IDString(id))
	data, _, err := fs.z.Get(unresolved)
	if err != nil && zutil.IsNoNode(err) {
		return err
	}
	if err != nil {
		panic(err)
	}

	// Write issue file in resolved
	if _, err = fs.z.Create(path.Join(fs.root, "resolved", issuefs.IDString(id)), data, 0, zutil.PermitAll); err != nil {
		panic(err)
	}

	// Remove issue file
	if err = fs.z.Delete(unresolved, -1); err != nil {
		panic(err)
	}
	return nil
}
Ejemplo n.º 2
0
func (fs *FS) Add(msg string /*, affected circuit.Addr*/) int64 {
	fs.Lock()
	defer fs.Unlock()

	// Crate issue structure
	issue := &issuefs.Issue{
		ID:       issuefs.ChooseID(),
		Time:     time.Now(),
		Reporter: circuit.WorkerAddr(),
		//Affected: affected,
		Anchor: anchorfs.Created(),
		Msg:    msg,
	}

	// Prepare body
	var w bytes.Buffer
	if err := gob.NewEncoder(&w).Encode(issue); err != nil {
		panic(err)
	}

	// Write to zookeeper
	if _, err := fs.z.Create(path.Join(fs.root, "unresolved", issuefs.IDString(issue.ID)), string(w.Bytes()), 0, zutil.PermitAll); err != nil {
		panic(err)
	}

	return issue.ID
}