I am facing an issue while attempting to create a TTL node. During the execution of the corresponding function, I consistently encounter an "invalid arguments" error. I have ensured that my parameters align with the function definition, yet the error persists. Could it be that I am using the function incorrectly?
The api:
// CreateTTL creates a TTL znode, which will be automatically deleted by server after the TTL.
func (c *Conn) CreateTTL(path string, data []byte, flags int32, acl []ACL, ttl time.Duration) (string, error) {
if err := validatePath(path, flags&FlagSequence == FlagSequence); err != nil {
return "", err
}
if flags&FlagTTL != FlagTTL {
return "", ErrInvalidFlags
}
res := &createResponse{}
_, err := c.request(opCreateTTL, &CreateTTLRequest{path, data, acl, flags, ttl.Milliseconds()}, res, nil)
return res.Path, err}
My code:
import "github.com/go-zookeeper/zk"
conn, _, err := zk.Connect( []string{"[***]:***"}, time.Second*5)
if err != nil {
hlog.Errorf("[ZK] Connect returned error: %v", err)
}
res, err := conn.CreateTTL("/test", []byte("ttl node"), zk.FlagTTL, zk.WorldACL(zk.PermAll), time.Second)
I try to changed the ttl, path, data paramter and still return this error
Now it works well I changed my flags into zk.FlagTTL|zk.FlagEphemeral but why?