Mercurial > gemma
diff pkg/imports/config.go @ 4178:51e90370eced
A few more doc strings to make 'golint' a little bit more happy with the imports package.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 05 Aug 2019 17:45:03 +0200 |
parents | 8b75ac5e243e |
children | 6270951dda28 |
line wrap: on
line diff
--- a/pkg/imports/config.go Mon Aug 05 17:16:46 2019 +0200 +++ b/pkg/imports/config.go Mon Aug 05 17:45:03 2019 +0200 @@ -29,11 +29,17 @@ // of the registered import types. ImportKind string + // ImportConfigIn is used to de-serialize JSON + // configurations coming from the REST endpoints + // to be stored in the database. ImportConfigIn struct { Kind ImportKind `json:"kind"` Config json.RawMessage `json:"config"` } + // ImportConfigOut is used to serialize + // JSON versions to the REST endpoints + // which are stored in the database. ImportConfigOut struct { ID int64 `json:"id"` Kind ImportKind `json:"kind"` @@ -41,6 +47,9 @@ Config interface{} `json:"config,omitempty"` } + // PersistentConfig is the the in-memory + // representation of a configuration + // which is stored in the database. PersistentConfig struct { ID int64 User string @@ -123,6 +132,7 @@ VALUES ($1, $2, $3)` ) +// UpdateContext stores an updated configuration to the database. func (pc *PersistentConfig) UpdateContext(ctx context.Context, tx *sql.Tx) error { if _, err := tx.ExecContext( ctx, @@ -141,6 +151,7 @@ return storeConfigAttributes(ctx, tx, pc.ID, pc.Attributes) } +// LoadPersistentConfigContext loads a configuration from the database. func LoadPersistentConfigContext( ctx context.Context, conn *sql.Conn, @@ -201,6 +212,9 @@ return cfg, err } +// ListAllPersistentConfigurationsContext iterates over all +// configurations stored in the database and reports every +// particular one to the callback fn. func ListAllPersistentConfigurationsContext( ctx context.Context, conn *sql.Conn, @@ -289,6 +303,9 @@ return err } +// DeletePersistentConfigurationContext deletes +// a configuration from the database identified by +// its id. func DeletePersistentConfigurationContext( ctx context.Context, tx *sql.Tx, @@ -350,6 +367,8 @@ return nil } +// StoreContext stores a configuration to the database and returns +// its new database id. func (pc *PersistentConfig) StoreContext(ctx context.Context, tx *sql.Tx) (int64, error) { var id int64 if err := tx.QueryRowContext(