mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 19:32:26 -05:00
[experiment] add alternative wasm sqlite3 implementation available via build-tag (#2863)
This allows for building GoToSocial with [SQLite transpiled to WASM](https://github.com/ncruces/go-sqlite3) and accessed through [Wazero](https://wazero.io/).
This commit is contained in:
parent
cce21c11cb
commit
1e7b32490d
398 changed files with 86174 additions and 684 deletions
|
|
@ -37,25 +37,9 @@ type ConfigState struct { //nolint
|
|||
|
||||
// NewState returns a new initialized ConfigState instance.
|
||||
func NewState() *ConfigState {
|
||||
viper := viper.New()
|
||||
|
||||
// Flag 'some-flag-name' becomes env var 'GTS_SOME_FLAG_NAME'
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||
viper.SetEnvPrefix("gts")
|
||||
|
||||
// Load appropriate named vals from env
|
||||
viper.AutomaticEnv()
|
||||
|
||||
// Create new ConfigState with defaults
|
||||
state := &ConfigState{
|
||||
viper: viper,
|
||||
config: Defaults,
|
||||
}
|
||||
|
||||
// Perform initial load into viper
|
||||
state.reloadToViper()
|
||||
|
||||
return state
|
||||
st := new(ConfigState)
|
||||
st.Reset()
|
||||
return st
|
||||
}
|
||||
|
||||
// Config provides safe access to the ConfigState's contained Configuration,
|
||||
|
|
@ -116,6 +100,32 @@ func (st *ConfigState) Reload() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// Reset will totally clear
|
||||
// ConfigState{}, loading defaults.
|
||||
func (st *ConfigState) Reset() {
|
||||
// Do within lock.
|
||||
st.mutex.Lock()
|
||||
defer st.mutex.Unlock()
|
||||
|
||||
// Create new viper.
|
||||
viper := viper.New()
|
||||
|
||||
// Flag 'some-flag-name' becomes env var 'GTS_SOME_FLAG_NAME'
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
||||
viper.SetEnvPrefix("gts")
|
||||
|
||||
// Load appropriate
|
||||
// named vals from env.
|
||||
viper.AutomaticEnv()
|
||||
|
||||
// Reset variables.
|
||||
st.viper = viper
|
||||
st.config = Defaults
|
||||
|
||||
// Load into viper.
|
||||
st.reloadToViper()
|
||||
}
|
||||
|
||||
// reloadToViper will reload Configuration{} values into viper.
|
||||
func (st *ConfigState) reloadToViper() {
|
||||
raw, err := st.config.MarshalMap()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue