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

firestore: Add .String() method to DocumentChangeKind #11578

Open
nathanperkins opened this issue Feb 11, 2025 · 1 comment · May be fixed by #11580
Open

firestore: Add .String() method to DocumentChangeKind #11578

nathanperkins opened this issue Feb 11, 2025 · 1 comment · May be fixed by #11580
Assignees
Labels
api: firestore Issues related to the Firestore API. triage me I really want to be triaged.

Comments

@nathanperkins
Copy link

nathanperkins commented Feb 11, 2025

Is your feature request related to a problem? Please describe.

I'm adding metrics to my database watch client. I want to know how many of each type of event we are seeing.

DocumentChangeKind is an integer so if we include that in our metric, we will see a number instead of a readable kind.

Describe the solution you'd like

Add a .String() method to type DocumentChangeKind int so that we can see the name of the event kind instead of a number.

type DocumentChangeKind int
const (
// DocumentAdded indicates that the document was added for the first time.
DocumentAdded DocumentChangeKind = iota
// DocumentRemoved indicates that the document was removed.
DocumentRemoved
// DocumentModified indicates that the document was modified.
DocumentModified
)

I'd like to make a PR for this, if it is approved. Here's the code I would add:

func (k firestore.DocumentChangeKind() string {
	switch k {
	case firestore.DocumentAdded:
		return "Added"
	case firestore.DocumentModified:
		return "Modified"
	case firestore.DocumentRemoved:
		return "Removed"
	default:
		return "Unknown"
	}
}

Describe alternatives you've considered

Maintaining my own would be annoying and problematic if Firestore adds more event kinds.

@nathanperkins nathanperkins added the triage me I really want to be triaged. label Feb 11, 2025
@product-auto-label product-auto-label bot added the api: firestore Issues related to the Firestore API. label Feb 11, 2025
nathanperkins added a commit to nathanperkins/google-cloud-go that referenced this issue Feb 11, 2025
The DocumentChangeKind.String() method returns a string representation
of the kind:

* DocumentAdded: "Added"
* DocumentModified: "Modified"
* DocumentRemoved: "Removed"

resolves googleapis#11578
nathanperkins added a commit to nathanperkins/google-cloud-go that referenced this issue Feb 11, 2025
The DocumentChangeKind.String() method returns a string representation
of the kind:

* DocumentAdded: "Added"
* DocumentModified: "Modified"
* DocumentRemoved: "Removed"

resolves googleapis#11578
@nathanperkins
Copy link
Author

PR is out for review: #11580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the Firestore API. triage me I really want to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants