func NewSetEntityNumber(c tree.RefContext) (tree.EntityHook, error) {
	return &SetEntityNumber{tree.NewBaseHook("set-entity-number", 50), c.DB}, nil
}
NewSetEntityNumber returns a SetEntityNumber hook ready for use.
package hooks
import (
	"github.com/netauth/netauth/internal/startup"
	"github.com/netauth/netauth/internal/tree"
	pb "github.com/netauth/protocol"
)
type SetEntityNumber struct {
	tree.BaseHook
	tree.DB
}
func (s *SetEntityNumber) Run(e, de *pb.Entity) error {
	if de.GetNumber() == -1 {
		n, err := s.NextEntityNumber()
		if err != nil {
			return err
		}
		e.Number = &n
		return nil
	}
	e.Number = de.Number
	return nil
}
func init() {
	startup.RegisterCallback(setEntityNumberCB)
}
func setEntityNumberCB() {
	tree.RegisterEntityHookConstructor("set-entity-number", NewSetEntityNumber)
}