api7 / etcd-adapter

Embed ETCD into your program in a lightweight manner
https://pkg.go.dev/github.com/api7/etcd-adapter
Apache License 2.0
72 stars 23 forks source link

feat: support configurability #6

Closed bzp2010 closed 2 years ago

bzp2010 commented 2 years ago

Supports configuration file and environment variable configuration.

bzp2010 commented 2 years ago

Update

Configuration files and corresponding CLI flag support have been added. It uses a configuration file in the following format, one part for configuring the HTTP/grpc server (not supported by TLS yet) and another part for the DSN. DSN currently supports mysql, if not for mysql will default back to btree.

server:
  host: 127.0.0.1
  port: 12379
# tls:
#   cert: /path/to/file.pem
#   key: /path/to/file.pem

dsn: mysql://root@tcp(127.0.0.1:3306)/apisix

This PR is currently based on the CLI branch, so it incorporates some of the original changes, and after the previous PR is merged I will do a rebase to reduce the chon

tokers commented 2 years ago

Update

Configuration files and corresponding CLI flag support have been added. It uses a configuration file in the following format, one part for configuring the HTTP/grpc server (not supported by TLS yet) and another part for the DSN. DSN currently supports mysql, if not for mysql will default back to btree.

server:
  host: 127.0.0.1
  port: 12379
# tls:
#   cert: /path/to/file.pem
#   key: /path/to/file.pem

dsn: mysql://root@tcp(127.0.0.1:3306)/apisix

This PR is currently based on the CLI branch, so it incorporates some of the original changes, and after the previous PR is merged I will do a rebase to reduce the chon

An explicit type field will be better than relying on the dsn, for btree, there is no concept of dsn, this is not a generic one.

bzp2010 commented 2 years ago

Update

These changes have been made since the last review.

This format of the configuration file is now. The configuration format of the data source is completely modified.

datasource:
  type: mysql
  mysql:
    host: 127.0.0.1
    port: 3306
    username: root
    password:
    database: apisix
bzp2010 commented 2 years ago

ping @tokers

tokers commented 2 years ago

CI was failed @bzp2010 .

bzp2010 commented 2 years ago

CI was failed @bzp2010 .

@tokers Need to merge the PR for fixing CI first, I will merge it to this one branch.

bzp2010 commented 2 years ago

Update

After merging CLI test fix patches, the CI issue has been resolved. Then, I added a reply about the gopkg log, you need to confirm it again. https://github.com/api7/etcd-adapter/pull/6#discussion_r820448849

ping @tokers @starsz