mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	feature: log queue and buffer memory size configuration (#6591)
* feature: log queue and buffer memory size configuration Signed-off-by: chenyuliang5 <chenyuliang@jd.com>
This commit is contained in:
		| @@ -3,6 +3,7 @@ package dnstap | ||||
| import ( | ||||
| 	"net/url" | ||||
| 	"os" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/coredns/caddy" | ||||
| @@ -20,7 +21,10 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) { | ||||
| 	dnstaps := []*Dnstap{} | ||||
|  | ||||
| 	for c.Next() { // directive name | ||||
| 		d := Dnstap{} | ||||
| 		d := Dnstap{ | ||||
| 			MultipleTcpWriteBuf: 1, | ||||
| 			MultipleQueue:       1, | ||||
| 		} | ||||
| 		endpoint := "" | ||||
| 		d.repl = replacer.New() | ||||
|  | ||||
| @@ -32,6 +36,14 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) { | ||||
|  | ||||
| 		endpoint = args[0] | ||||
|  | ||||
| 		if len(args) >= 3 { | ||||
| 			d.MultipleTcpWriteBuf, _ = strconv.Atoi(args[2]) | ||||
| 		} | ||||
|  | ||||
| 		if len(args) >= 4 { | ||||
| 			d.MultipleQueue, _ = strconv.Atoi(args[3]) | ||||
| 		} | ||||
|  | ||||
| 		var dio *dio | ||||
| 		if strings.HasPrefix(endpoint, "tls://") { | ||||
| 			// remote network endpoint | ||||
| @@ -39,23 +51,23 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) { | ||||
| 			if err != nil { | ||||
| 				return nil, c.ArgErr() | ||||
| 			} | ||||
| 			dio = newIO("tls", endpointURL.Host) | ||||
| 			d = Dnstap{io: dio} | ||||
| 			dio = newIO("tls", endpointURL.Host, d.MultipleQueue, d.MultipleTcpWriteBuf) | ||||
| 			d.io = dio | ||||
| 		} else if strings.HasPrefix(endpoint, "tcp://") { | ||||
| 			// remote network endpoint | ||||
| 			endpointURL, err := url.Parse(endpoint) | ||||
| 			if err != nil { | ||||
| 				return nil, c.ArgErr() | ||||
| 			} | ||||
| 			dio = newIO("tcp", endpointURL.Host) | ||||
| 			d = Dnstap{io: dio} | ||||
| 			dio = newIO("tcp", endpointURL.Host, d.MultipleQueue, d.MultipleTcpWriteBuf) | ||||
| 			d.io = dio | ||||
| 		} else { | ||||
| 			endpoint = strings.TrimPrefix(endpoint, "unix://") | ||||
| 			dio = newIO("unix", endpoint) | ||||
| 			d = Dnstap{io: dio} | ||||
| 			dio = newIO("unix", endpoint, d.MultipleQueue, d.MultipleTcpWriteBuf) | ||||
| 			d.io = dio | ||||
| 		} | ||||
|  | ||||
| 		d.IncludeRawMessage = len(args) == 2 && args[1] == "full" | ||||
| 		d.IncludeRawMessage = len(args) >= 2 && args[1] == "full" | ||||
|  | ||||
| 		hostname, _ := os.Hostname() | ||||
| 		d.Identity = []byte(hostname) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user