You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apisix.apache.org by wei jin <kv...@apache.org> on 2021/03/01 03:45:39 UTC

[DISCUSS] Use label instead of ID

Currently APISIX contains many objects, route/service/upstream/plugin, and
they are related by ID.
Although using ID to manager relations between objects is easy to
understand and can accomplish most things, but I think the way of ID is not
a final solution, we should use the form of label-selector to associate
objects.

There are two reasons:

1. Using ID means adding a relationship, or an object will need to add a
xxx_id field to other existed objects, such as service_id, upstream_id, or
other id in route. If it is a many-to-many relationship, you also need a
xxx_ids, or a template_id, and then encapsulate multiple ids in the
template, such as plugin_config_id in route.

2. Service deployment and some batch processing (such as multi-cluster
replication) is a multi-dimensional structure, for example, multiple
clusters, multiple partitions, multiple issuance sequences, application
hierarchical management and other practical situations, especially due to
infrastructure rather than The multi-dimensional structure caused by the
logical division of users. We cannot use id to pass in the
multi-dimensional structure, resulting in the configuration cannot be
passed and reused.

Of course, using label-selector to organize object relationships brings
some benefits, but it also increases the complexity of the implementation.
For example, when a label is modified or the selection condition of a
selector is modified, the corresponding object needs to be notified. Of
course, this can also be implemented in other life cycles, such as query or
timing operations.
What do you think?

Re: [DISCUSS] Use label instead of ID

Posted by wei jin <kv...@apache.org>.
I also created a discuss issue here:
https://github.com/apache/apisix/issues/3704

wei jin <kv...@apache.org> 于2021年3月1日周一 上午11:45写道:

> Currently APISIX contains many objects, route/service/upstream/plugin, and
> they are related by ID.
> Although using ID to manager relations between objects is easy to
> understand and can accomplish most things, but I think the way of ID is not
> a final solution, we should use the form of label-selector to associate
> objects.
>
> There are two reasons:
>
> 1. Using ID means adding a relationship, or an object will need to add a
> xxx_id field to other existed objects, such as service_id, upstream_id, or
> other id in route. If it is a many-to-many relationship, you also need a
> xxx_ids, or a template_id, and then encapsulate multiple ids in the
> template, such as plugin_config_id in route.
>
> 2. Service deployment and some batch processing (such as multi-cluster
> replication) is a multi-dimensional structure, for example, multiple
> clusters, multiple partitions, multiple issuance sequences, application
> hierarchical management and other practical situations, especially due to
> infrastructure rather than The multi-dimensional structure caused by the
> logical division of users. We cannot use id to pass in the
> multi-dimensional structure, resulting in the configuration cannot be
> passed and reused.
>
> Of course, using label-selector to organize object relationships brings
> some benefits, but it also increases the complexity of the implementation.
> For example, when a label is modified or the selection condition of a
> selector is modified, the corresponding object needs to be notified. Of
> course, this can also be implemented in other life cycles, such as query or
> timing operations.
> What do you think?
>