Skip to content

feat!: take a base Definition in objectidproto and cache definitions per type - #3

Merged
enilsen16 merged 9 commits into
mainfrom
feat/proto-definition-options
Oct 22, 2026
Merged

enilsen16 merged 9 commits into
mainfrom
feat/proto-definition-options

Conversation

@enilsen16

@enilsen16 enilsen16 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #2.

Summary

  • objectidproto.Definition(enum, base) and MustDefinition(enum, base) read ObjectType and Separator from the annotation over a base Definition. Each type is then one package-level variable, the same way the Elixir use Trogon.ObjectId, proto: {...}, validate: :uuid declares it. A new Definition field, such as Aliases in feat: accept earlier prefixes with Definition.Aliases #8, works with no change here. This breaks v0.1.0's Definition(enum).
  • One generic cache (cache.go) stores each type's spec by reflect.Type, as a pointer, for both IDs and unions. Definition must return the same value every time, and the docs say so.
  • ObjectTypeOf[T]() and PrefixOf[T]() read the type's object type and prefix without an ID. They are the Go form of the Elixir module functions object_type/0 and prefix/0. The ID methods call them.

Benchmarks (Apple M5 Max)

v0.1.0 Now
String about 45 ns, 2 allocs 20 ns, 1 alloc
Parse 1 alloc 22 ns, 0 allocs

Tests

The tests cover the base overlay, a check that Definition runs once across String and Parse, the type-level accessors, and the benchmarks. CI runs only on PRs to main. Locally, go test -race, go vet and golangci-lint pass.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e40e5b13-e74a-4904-9253-2062fd761b8f
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options

Signed-off-by: Erik Nilsen <enilsen16@live.com>
…ition

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid_test.go
@enilsen16 enilsen16 changed the title feat: add proto definition options and cache definitions per type feat!: take a base Definition in objectidproto and cache definitions per type Oct 22, 2026
Base automatically changed from feat/normalize-and-spanner to main October 22, 2026 14:29
@enilsen16
enilsen16 marked this pull request as ready for review October 22, 2026 14:30
…-options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectid_test.go
…-options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectid_test.go
@enilsen16
enilsen16 merged commit 8d466df into main Oct 22, 2026
3 checks passed
@enilsen16
enilsen16 deleted the feat/proto-definition-options branch October 22, 2026 16:06
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.

1 participant