Exemple #1
0
// get a temporary file we can use for read/write that deletes itself on close
func (fs FilesystemStorage) obtainTempFile() (f *os.File, err error) {
	fname := fmt.Sprintf("tempfile-%x-%d", crypto.RandBytes(4), time.Now().Unix())
	log.WithFields(log.Fields{
		"pkg":      "fs-store",
		"filepath": fname,
	}).Debug("opening temp file")
	f, err = os.OpenFile(filepath.Join(fs.TempDir(), fname), os.O_RDWR, os.ModeTemporary)
	return
}
Exemple #2
0
// generate a new message id given name of server
func GenMessageID(name string) MessageID {
	r := crypto.RandBytes(4)
	t := time.Now()
	return MessageID(fmt.Sprintf("<%x$%d@%s>", r, t.Unix(), name))
}