mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
Add more options to the plugin
Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -39,11 +39,11 @@ The extended syntax (not implemented; everything is hard-coded at the moment):
|
|||||||
~~~
|
~~~
|
||||||
traffic {
|
traffic {
|
||||||
server grpc://dsdsd <creds>
|
server grpc://dsdsd <creds>
|
||||||
id ID
|
node ID
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
* id **ID** is how *traffic* identifies itself to the control plane.
|
* node **ID** is how *traffic* identifies itself to the control plane. This defaults to `coredns`.
|
||||||
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|||||||
@@ -51,13 +51,18 @@ func setup(c *caddy.Controller) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parse(c *caddy.Controller) error {
|
func parse(c *caddy.Controller) (*Traffic, error) {
|
||||||
for c.Next() {
|
for c.Next() {
|
||||||
args := c.RemainingArgs()
|
args := c.RemainingArgs()
|
||||||
if len(args) != 0 {
|
if len(args) != 0 {
|
||||||
return c.ArgErr()
|
return nil, c.ArgErr()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
for c.NextBlock() {
|
||||||
|
switch c.Val() {
|
||||||
|
case "id":
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ import (
|
|||||||
// Traffic is a plugin that load balances according to assignments.
|
// Traffic is a plugin that load balances according to assignments.
|
||||||
type Traffic struct {
|
type Traffic struct {
|
||||||
c *xds.Client
|
c *xds.Client
|
||||||
|
id string
|
||||||
Next plugin.Handler
|
Next plugin.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a pointer to a new and initialized Traffic.
|
// New returns a pointer to a new and initialized Traffic.
|
||||||
func New() (*Traffic, error) {
|
func New(addr, node string) (*Traffic, error) {
|
||||||
c, err := xds.New(":18000", "mycoredns")
|
c, err := xds.New(":18000", "mycoredns")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ type Client struct {
|
|||||||
|
|
||||||
// New returns a new client that's dialed to addr using node as the local identifier.
|
// New returns a new client that's dialed to addr using node as the local identifier.
|
||||||
func New(addr, node string) (*Client, error) {
|
func New(addr, node string) (*Client, error) {
|
||||||
// todo credentials
|
// todo credentials!
|
||||||
opts := []grpc.DialOption{grpc.WithInsecure()}
|
opts := []grpc.DialOption{grpc.WithInsecure()}
|
||||||
cc, err := grpc.Dial(addr, opts...)
|
cc, err := grpc.Dial(addr, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user