Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kuma-cp) Added creation and modification time to core entities #521

Merged
merged 5 commits into from
Feb 4, 2020

Conversation

jakubdyszkiewicz
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz commented Jan 2, 2020

Summary

Added creation and modification time to core entities including postgres migration.

It's not yet exposed on kumactl/API server. If we want to expose it on API side, lets discuss it and do it as a separate PR.
On K8S there is no distinction between creation and modification date therefore we always use creation time.

@jakubdyszkiewicz jakubdyszkiewicz marked this pull request as ready for review January 27, 2020 13:29
@jakubdyszkiewicz jakubdyszkiewicz requested review from a team and yskopets January 27, 2020 13:29
statement := `INSERT INTO resources VALUES ($1, $2, $3, $4, $5, $6);`
_, err = r.db.Exec(statement, opts.Name, "", opts.Mesh, resource.GetType(), version, string(bytes)) // todo(jakubdyszkiewicz) solve db migration
statement := `INSERT INTO resources VALUES ($1, $2, $3, $4, $5, $6, $7, $8);`
now := time.Now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why creationTime/modificationTime is set at DAO layer instead of Service layer ?

@@ -107,11 +111,13 @@ func (r *postgresResourceStore) Update(_ context.Context, resource model.Resourc
if err != nil {
return errors.Wrap(err, "failed to convert meta version to int")
}
statement := `UPDATE resources SET spec=$1, version=$2 WHERE name=$3 AND mesh=$4 AND type=$5 AND version=$6;`
statement := `UPDATE resources SET spec=$1, version=$2, modification_time=$3 WHERE name=$4 AND mesh=$5 AND type=$6 AND version=$7;`
now := time.Now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why modificationTime is set at DAO layer instead of Service layer ?

@@ -74,10 +85,13 @@ func (c *memoryStore) Create(_ context.Context, r model.Resource, fs ...store.Cr
return store.ErrorResourceAlreadyExists(r.GetType(), opts.Name, opts.Mesh)
}

now := time.Now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why creationTime/modificationTime is set at DAO layer instead of Service layer ?

@@ -114,6 +128,7 @@ func (c *memoryStore) Update(_ context.Context, r model.Resource, fs ...store.Up
return store.ErrorResourceConflict(r.GetType(), r.GetMeta().GetName(), r.GetMeta().GetMesh())
}
meta.Version = meta.Version.Next()
meta.ModificationTime = time.Now()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why modificationTime is set at DAO layer instead of Service layer ?

@jakubdyszkiewicz jakubdyszkiewicz merged commit e5f83b3 into master Feb 4, 2020
@jakubdyszkiewicz jakubdyszkiewicz deleted the feature/creation-date branch February 28, 2020 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants