Exemplo n.º 1
0
// AddRecord adds a record to the persistent cache
func AddRecord(resource *shaman.Resource) error {
	if storage == nil {
		return nil
	}
	resource.Validate()
	return storage.addRecord(*resource)
}
Exemplo n.º 2
0
// UpdateRecord updates a record to a resource(domain)
func UpdateRecord(domain string, resource *sham.Resource) error {
	resource.Validate()
	sham.SanitizeDomain(&domain)

	// in case of some update to domain name...
	if domain != resource.Domain {
		// delete old domain
		err := DeleteRecord(domain)
		if err != nil {
			return fmt.Errorf("Failed to clean up old domain - %v", err)
		}
	}

	// store in cache
	config.Log.Trace("Updating record in persistent cache...")
	err := cache.UpdateRecord(domain, resource)
	if err != nil {
		return err
	}

	// set new resource to domain
	// todo: atomic
	Answers[resource.Domain] = *resource

	return nil
}
Exemplo n.º 3
0
// UpdateRecord updates a record in the persistent cache
func UpdateRecord(domain string, resource *shaman.Resource) error {
	if storage == nil {
		return nil
	}
	shaman.SanitizeDomain(&domain)
	resource.Validate()
	return storage.updateRecord(domain, *resource)
}