import "github.com/influxdb/influxdb/meta" func createDB(db string) error { // create a new Meta client client, err := meta.NewClient(meta.DefaultConfig()) if err != nil { return err } // create a new database err = client.CreateDatabase(db) if err != nil { return err } return nil }
import "github.com/influxdb/influxdb/meta" func modifyRetentionPolicy(db, rp string, duration time.Duration) error { // create a new Meta client client, err := meta.NewClient(meta.DefaultConfig()) if err != nil { return err } // find the database and retention policy database, err := client.Database(db) if err != nil { return err } retentionPolicy, err := database.RetentionPolicy(rp) if err != nil { return err } // modify the duration of the retention policy retentionPolicy.Duration = duration // update the retention policy err = client.UpdateRetentionPolicy(database.Name, retentionPolicy.Name, retentionPolicy) if err != nil { return err } return nil }This code modifies the duration of a retention policy of a given database. It first creates a new Meta client, finds the database and retention policy using the `Database()` and `RetentionPolicy()` functions respectively, updates the duration of the retention policy and then calls the `UpdateRetentionPolicy()` function to update the retention policy in the metadata. In conclusion, the package library for the given code examples is `github.com/influxdb/influxdb/meta`.