Support for thrift annotation auth.actor_uuidAnnotate - #2463
Conversation
|
|
|
If my understanding is correct, this won't work with: service TestService {
string testMethod(1: string notInterested, 2: string interested (auth.actor_uuid = "true"))
} |
How's this intended to be consumed? By who? Should we add something like this?
Otherwise consumers will need to define it themselves |
| for _, field := range ss.Fields { | ||
| if _, ok := field.Annotations[_UUIDAnnotationKey]; ok { | ||
| if prevValue, pres := annotatedTypes[ss]; pres { | ||
| return map[*compile.StructSpec]string{}, fmt.Errorf("multiple fields annotated with %s for type %s. Prev %s; Duplicate at %s", |
There was a problem hiding this comment.
generated code assumes *string but somthing like required string UserID generates UserID string, so uuid != nil is always true and *uuid won't compile.
There was a problem hiding this comment.
interesting, good catch!
| // and re-compile it. Plugins do not actually have access to the original | ||
| // thrift file's module, and this is how we gain access to it, since this | ||
| // generator writes extra methods to exception types defined in the Thrift | ||
| // file. |
There was a problem hiding this comment.
copied from exception.go?
| @@ -0,0 +1,6 @@ | |||
|
|
|||
There was a problem hiding this comment.
empty line on each new .thrift
| } | ||
|
|
||
| templateOptions := append(templateOptions, | ||
| plugin.TemplateFunc("getAllAnnotatedTypes", func() map[*compile.StructSpec]string { |
There was a problem hiding this comment.
Can this lead to a data race if this and the exceptions generator call try to write?
There was a problem hiding this comment.
they're executed sequentially, can you expand on the concern here?
What?
Add support for thrift annotation "auth.actor_uuid".
Why?
This supports validation for these fields.
RELEASE NOTES:
Added support for annotation auth.actor_uuid