<commit_before>// Copyright 2017 Apcera Inc. All rights reserved.

package server

import (
	"crypto/tls"
	"errors"
	"fmt"
	"reflect"
	"strings"
)

// FlagSnapshot captures the server options as specified by CLI flags at
// startup. This should not be modified once the server has started.
var FlagSnapshot *Options

// option is a hot-swappable configuration setting.
type option interface {
	// Apply the server option.
	Apply(server *Server)
}

// traceOption implements the option interface for the `trace` setting.
type traceOption struct {
	newValue bool
}

// Apply the tracing change by reconfiguring the server's logger.
func (t *traceOption) Apply(server *Server) {
	server.ConfigureLogger()
	server.Noticef("Reloaded: trace = %v", t.newValue)
}

// debugOption implements the option interface for the `debug` setting.
type debugOption struct {
	newValue bool
}

// Apply the debug change by reconfiguring the server's logger.
func (d *debugOption) Apply(server *Server) {
	server.ConfigureLogger()
	server.Noticef("Reloaded: debug = %v", d.newValue)
}

// tlsOption implements the option interface for the `tls` setting.
type tlsOption struct {
	newValue *tls.Config
}

// Apply the tls change.
func (t *tlsOption) Apply(server *Server) {
	tlsRequired := t.newValue != nil
	server.info.TLSRequired = tlsRequired
	server.info.TLSVerify = tlsRequired && t.newValue.ClientAuth == tls.RequireAndVerifyClientCert
	server.generateServerInfoJSON()
	server.Noticef("Reloaded: tls")
}

// Reload reads the current configuration file and applies any supported
// changes. This returns an error if the server was not started with a config
// file or an option which doesn't support hot-swapping was changed.
func (s *Server) Reload() error {
	s.mu.Lock()
	defer s.mu.Unlock()<commit_msg>Improve readability of TLSVerify assignment<commit_after>// Copyright 2017 Apcera Inc. All rights reserved.

package server

import (
	"crypto/tls"
	"errors"
	"fmt"
	"reflect"
	"strings"
)

// FlagSnapshot captures the server options as specified by CLI flags at
// startup. This should not be modified once the server has started.
var FlagSnapshot *Options

// option is a hot-swappable configuration setting.
type option interface {
	// Apply the server option.
	Apply(server *Server)
}

// traceOption implements the option interface for the `trace` setting.
type traceOption struct {
	newValue bool
}

// Apply the tracing change by reconfiguring the server's logger.
func (t *traceOption) Apply(server *Server) {
	server.ConfigureLogger()
	server.Noticef("Reloaded: trace = %v", t.newValue)
}

// debugOption implements the option interface for the `debug` setting.
type debugOption struct {
	newValue bool
}

// Apply the debug change by reconfiguring the server's logger.
func (d *debugOption) Apply(server *Server) {
	server.ConfigureLogger()
	server.Noticef("Reloaded: debug = %v", d.newValue)
}

// tlsOption implements the option interface for the `tls` setting.
type tlsOption struct {
	newValue *tls.Config
}

// Apply the tls change.
func (t *tlsOption) Apply(server *Server) {
	tlsRequired := t.newValue != nil
	server.info.TLSRequired = tlsRequired
	if tlsRequired {
		server.info.TLSVerify = (t.newValue.ClientAuth == tls.RequireAndVerifyClientCert)
	}
	server.generateServerInfoJSON()
	server.Noticef("Reloaded: tls")
}

// Reload reads the current configuration file and applies any supported
// changes. This returns an error if the server was not started with a config
// file or an option which doesn't support hot-swapping was changed.
func (s *Server) Reload() error {
	s.mu.Lock()
	defer s.mu.Unlock()
{'fraction_non_alphanumeric': 0.09687240520343206, 'fraction_numerical': 0.0022142264046498754, 'mean_word_length': 4.330383480825959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1628650', 'n_tokens_mistral': 1091, 'n_tokens_neox': 1068, 'n_words': 402}