-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[request] Additional Metadata stored w/ the Consumer #550
Comments
👍 |
@thibaultcha does current lua-cassandra support inserting rows map data type ? if not, this could be implemented using json string (text data type) in the custom_data field. |
Yes it does. However I think one can relatively safely assume two things from this feature: users will want to store arbitrary values (strings, numbers, arrays, other maps...) and users will want to query their consumers based on those metadata values. Unfortunately for this use case Cassandra is not schema-less, which makes this feature nearly impossible to be implemented in an efficient way. Doing this with a Happy to hear about a solution. |
Yeah that seems reasonable. In my particular use-case I wouldn't need to query the field, so a text With that said I think my use case may be specific enough to warrant a
|
+1 That would also be really nice if we could use these metadatas in the api plugins. something like: name: "request-transformer"
ensure: "present"
attributes:
config.add.querystring: "api-key:{remote-api-key-from-metadata}" |
+1, and as mentioned it would be really nice if we can use these values in the request transformer. I don't want to query my consumers based on this values as mentioned @thibaultcha and I don't need specific types. If it is possible to use these values to transform requests that would be more than enough from my point of view. |
Totally agree with that, this is basic usage. We need meta on our end as well. |
I need a proof of concept of a Metadata plugin that can alter request or emit values usable by the request transformer plugin. I will start working on it in the next few days because our company need it for January. Does anyone have already a proof of concept of this or a good idea how it should be builded ? I've never done Lua before but I have a good knowledge of nginx. Useful doc : Anything else ? |
Haven't given this a lot of thought, but how about combining it with regex support. Basically 2 types of plugins.
This would allow any future plugin to add stuff to that table and be able to insert/re-use that in the data-insertion part. does that make sense, or am I talking rubbish? |
The #2 seems pretty much like something needed, but the #1 is not exactly how I imagined things. What I need to do for my needs is to be able to persist additionnal data in database for the consumers (permanently), and re-use that data in request transformation. I'll provide an example of how I see the configuration taking form when we request the plugins configuration of an API on http://X.X.X.X:8001/apis/id/plugins in few minutes |
Sorry it took time, just got out of a meeting So from my point of view, I think the json representation of the consumer-metadata plugin could look like this (a bunch of key-value data linked to consumers) :
And the maybe we could access that data from the request-transformer,
Again, this is the way I see it at the moment, so I can accomplish what I need to do for my employer needs. I'm open to new suggestions and comments if you think you have a better approach. |
@JnMik the request-transformer-plugin won't have access to the config of the metadata-plugin. Hence you must use the metadata-plugin to store the relevant data in the |
I see, so plugins cannot interact with other plugins. So let's consider the plugin config should have the two configuration blocs you mentionned (data-provisioning and data-insertion). We should also consider data-provisioning can be feed from regex extraction or static provided values. You mentionned having your Regex extraction storing a value derived from excuting the regex, is that a requirement for you ? Could the extraction result only be passed through the data_insertion procedure on the fly and not stored in database ? Since the extraction is mostly to get a value from the current volatile request, what's the +value of storing that data ? Let me try another example of json and see if it is more valuable to you :
Waiting for your input on this one :) |
@Tieske Hello Again! So far I managed to make kong-vagrant works, create a plugin with some dummy data and build unit test for it. So I'm starting working on the real deal, and I realize there is stuff that I could re-use from the request-transformer plugin. Functions like transform_querystrings() at least. If you want me to move it, do you have an idea for naming the thing ? (request_transform.lua, querystring_transform.lua, or create some kind of querystring_factory.lua handling array of args in constructor ?) Being new to Lua and to this project, I'm not confortable moving stuff around without asking lol Edit: Maybe moving it around would imply having to do some refactor to for a better decoupling. |
I mentioned the The specific table see also; https://github.com/openresty/lua-nginx-module#ngxctx hth |
For now, just copy it, but mark it with a comment that is is a copy and we'll see later about refactoring it. Additionally on your json snippet; see my remark above on the |
Oh yes, I have discovered about Lua table lol xD I'll see what I can do, inspiring myself from other plugins. thx ! |
@Tieske I would like your advise regarding some business logic, let's say I have 2 consumers, Both users try to query some API route which try to forward that metadata field to the micro service behind. What should happend to the second user ? #1 Request is forwarded with an empty value in the metadata field Thx buddy ! P.S I'm currently building all the api.lua / Daos / Hooks facets, starting to enjoy it ;) |
I have chosen the scenario #2 for now |
Yeah, it would be useful |
Today theres no way to pass a metadata when creating a consumer? |
@danilobreda only the |
It's supported in Kong 1.1 |
any doc référence would be usefull |
@izio38 use tags, see https://docs.konghq.com/1.2.x/admin-api/#tags |
@guanlan, what happened to this metadata support feature? Was it completed? |
@chienhsingwu see the |
@Tieske, I am not sure how tags can be use for meta data, which are name-value pairs, while tags are just names. |
it's a different form, but both are metadata. If you want name-value pairs; don't hold your breath, I haven't seen anything like that in the works. |
Thanks @Tieske. I guess the only option is to implement one that just fit my purpose specifically? |
We have a few additional attributes outside of
custom_id
we'd like to store w/ the consumer record and then expose through headers to the downstream services.This could be achieved w/ a
custom_data
map column on theconsumers
table:This would allow users to add a tiny bit of extra free-form metadata in a JSON-style map.
An alternative could be a separate table
consumer_data
where additional key-value pairs could be stored. The upside of the alternate table is it could be managed as a plugin w/ it's own migrations.The text was updated successfully, but these errors were encountered: