Example #1
0
func (self *Queue) open() error {
	self.Lock()
	defer self.Unlock()
	if regexp.MustCompile(`[^a-zA-Z0-9_]+`).MatchString(self.Name) {
		return errors.New("Queue name is not alphanumeric")
	}

	if len(self.Name) > 100 {
		return errors.New("Queue name is too long")
	}

	var options opt.Options
	options.BlockCacher = opt.NoCacher

	var err error
	self.db, err = leveldb.OpenFile(self.Path(), &options)
	if err != nil {
		return err
	}
	self.isOpened = true
	return self.initialize()
}