parent
20060c28fd
commit
b714acbc5b
@ -0,0 +1,3 @@
|
||||
module results
|
||||
|
||||
go 1.22
|
||||
@ -1,3 +0,0 @@
|
||||
module rsts
|
||||
|
||||
go 1.22
|
||||
@ -0,0 +1,109 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// ABool
|
||||
// Type: Struct
|
||||
// Desc: Atomic Bool, estructura para realizar operaciones atomicas
|
||||
// sobre un valor de tipo Bool
|
||||
//
|
||||
ABool struct {
|
||||
|
||||
// value: valor sobre el que se realizaran las operaciones
|
||||
// atomicas.
|
||||
//
|
||||
value uint32
|
||||
}
|
||||
)
|
||||
|
||||
// NewABool
|
||||
// Desc: Función constructor para ABool
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewABool(val bool) *ABool { return &ABool{value: boolAsUint32(val)} }
|
||||
|
||||
// ABool.Get
|
||||
// Desc:
|
||||
// Rets:
|
||||
//
|
||||
func (b *ABool) Get() bool { return atomic.LoadUint32(&b.value) == 1 }
|
||||
|
||||
// ABool.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
//
|
||||
func (b *ABool) Set(val bool) { atomic.StoreUint32(&b.value, boolAsUint32(val)) }
|
||||
|
||||
// ABool.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
//
|
||||
func (b *ABool) Swap(new bool) bool { return atomic.SwapUint32(&b.value, boolAsUint32(new)) == 1 }
|
||||
|
||||
// ABool.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (b *ABool) CAS(old, new bool) bool {
|
||||
return atomic.CompareAndSwapUint32(&b.value, boolAsUint32(old), boolAsUint32(new))
|
||||
}
|
||||
|
||||
// boolAsUint32
|
||||
// Desc: Convierte un valor de tipo bool a uint32
|
||||
// Prms: val, valor a convertir
|
||||
// Rets: uint32, El valor segun sea true = 1 o
|
||||
// false = *
|
||||
//
|
||||
func boolAsUint32(val bool) uint32 {
|
||||
if val {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,117 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// ADuration
|
||||
// Type: Struct
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
//
|
||||
ADuration struct {
|
||||
value int64
|
||||
}
|
||||
)
|
||||
|
||||
// NewADuration
|
||||
// Desc: Función constructor para ADuration
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewADuration(val time.Duration) *ADuration { return &ADuration{value: int64(val)} }
|
||||
|
||||
// ADuration.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ADuration) Get() time.Duration { return time.Duration(atomic.LoadInt64(&i.value)) }
|
||||
|
||||
// ADuration.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ADuration) Set(val time.Duration) { atomic.StoreInt64(&i.value, int64(val)) }
|
||||
|
||||
// ADuration.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ADuration) Swap(new time.Duration) time.Duration {
|
||||
return time.Duration(atomic.SwapInt64(&i.value, int64(new)))
|
||||
}
|
||||
|
||||
// ADuration.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ADuration) Add(dlt time.Duration) time.Duration {
|
||||
return time.Duration(atomic.AddInt64(&i.value, int64(dlt)))
|
||||
}
|
||||
|
||||
// ADuration.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ADuration) Sub(dlt time.Duration) time.Duration {
|
||||
return time.Duration(atomic.AddInt64(&i.value, int64(-dlt)))
|
||||
}
|
||||
|
||||
// ADuration.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ADuration) CAS(old, new time.Duration) bool {
|
||||
return atomic.CompareAndSwapInt64(&i.value, int64(old), int64(new))
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,90 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// AError
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
//
|
||||
AError struct {
|
||||
value atomic.Value
|
||||
}
|
||||
)
|
||||
|
||||
// NewAError
|
||||
// Desc: Función constructor para AError
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewAError(err error) *AError {
|
||||
ae := &AError{}
|
||||
if err != nil {
|
||||
ae.value.Store(err)
|
||||
}
|
||||
return ae
|
||||
}
|
||||
|
||||
// AError.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (a *AError) Set(err error) { a.value.Store(err) }
|
||||
|
||||
// AError.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (a *AError) Get() error {
|
||||
if vl := a.value.Load(); vl != nil {
|
||||
return vl.(error)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,121 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// AInt32
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
//
|
||||
AInt32 struct {
|
||||
value int32
|
||||
}
|
||||
)
|
||||
|
||||
// NewAInt32
|
||||
// Desc: Función constructor para AInt32
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewAInt32(val int32) *AInt32 { return &AInt32{value: val} }
|
||||
|
||||
// AInt32.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) Get() int32 { return atomic.LoadInt32(&i.value) }
|
||||
|
||||
// AInt32.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) Set(val int32) { atomic.StoreInt32(&i.value, val) }
|
||||
|
||||
// AInt32.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) Swap(new int32) int32 { return atomic.SwapInt32(&i.value, new) }
|
||||
|
||||
// AInt32.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) Add(dlt int32) int32 { return atomic.AddInt32(&i.value, dlt) }
|
||||
|
||||
// AInt32.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) Sub(dlt int32) int32 { return atomic.AddInt32(&i.value, -dlt) }
|
||||
|
||||
// AInt32.Inc
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) Inc() int32 { return i.Add(1) }
|
||||
|
||||
// AInt32.Dec
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) Dec() int32 { return i.Add(-1) }
|
||||
|
||||
// AInt32.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt32) CAS(old, new int32) bool { return atomic.CompareAndSwapInt32(&i.value, old, new) }
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,121 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// AInt64
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
//
|
||||
AInt64 struct {
|
||||
value int64
|
||||
}
|
||||
)
|
||||
|
||||
// NewAInt64
|
||||
// Desc: Función constructor para AInt64
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewAInt64(val int64) *AInt64 { return &AInt64{value: val} }
|
||||
|
||||
// AInt64.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) Get() int64 { return atomic.LoadInt64(&i.value) }
|
||||
|
||||
// AInt64.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) Set(val int64) { atomic.StoreInt64(&i.value, val) }
|
||||
|
||||
// AInt64.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) Swap(new int64) int64 { return atomic.SwapInt64(&i.value, new) }
|
||||
|
||||
// AInt64.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) Add(dlt int64) int64 { return atomic.AddInt64(&i.value, dlt) }
|
||||
|
||||
// AInt64.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) Sub(dlt int64) int64 { return atomic.AddInt64(&i.value, -dlt) }
|
||||
|
||||
// AInt64.Inc
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) Inc() int64 { return i.Add(1) }
|
||||
|
||||
// AInt64.Dec
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) Dec() int64 { return i.Add(-1) }
|
||||
|
||||
// AInt64.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *AInt64) CAS(old, new int64) bool { return atomic.CompareAndSwapInt64(&i.value, old, new) }
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,155 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// ANanos
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
//
|
||||
ANanos struct {
|
||||
value int64
|
||||
}
|
||||
)
|
||||
|
||||
// NewANanos
|
||||
// Desc: Función constructor para ANanos
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewANanos(val time.Duration) *ANanos { return &ANanos{value: int64(val)} }
|
||||
|
||||
// ANanos.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) Get() time.Duration { return time.Duration(atomic.LoadInt64(&i.value)) }
|
||||
|
||||
// ANanos.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) Set(val time.Duration) { atomic.StoreInt64(&i.value, int64(val)) }
|
||||
|
||||
// ANanos.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) Swap(new time.Duration) time.Duration {
|
||||
return time.Duration(atomic.SwapInt64(&i.value, int64(new)))
|
||||
}
|
||||
|
||||
// ANanos.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) Add(dlt time.Duration) time.Duration {
|
||||
return time.Duration(atomic.AddInt64(&i.value, int64(dlt)))
|
||||
}
|
||||
|
||||
// ANanos.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) Sub(dlt time.Duration) time.Duration {
|
||||
return time.Duration(atomic.AddInt64(&i.value, int64(-dlt)))
|
||||
}
|
||||
|
||||
// ANanos.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) CAS(old, new time.Duration) bool {
|
||||
return atomic.CompareAndSwapInt64(&i.value, int64(old), int64(new))
|
||||
}
|
||||
|
||||
// ANanos.GetTime
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) GetTime() time.Time { return time.Unix(0, atomic.LoadInt64(&i.value)) }
|
||||
|
||||
// ANanos.SetTime
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) SetTime(val time.Time) { atomic.StoreInt64(&i.value, val.UnixNano()) }
|
||||
|
||||
// ANanos.GetNanos
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) GetNanos() int64 { return atomic.LoadInt64(&i.value) }
|
||||
|
||||
// ANanos.SetNanos
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) SetNanos(val int64) { atomic.StoreInt64(&i.value, val) }
|
||||
|
||||
// ANanos.SetNow
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (i *ANanos) SetNow() time.Time {
|
||||
nw := time.Now()
|
||||
i.SetTime(nw)
|
||||
return nw
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,121 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// AUInt32
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
//
|
||||
AUInt32 struct {
|
||||
value uint32
|
||||
}
|
||||
)
|
||||
|
||||
// NewAUInt32
|
||||
// Desc: Función constructor para AUInt32
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewAUInt32(val uint32) *AUInt32 { return &AUInt32{value: val} }
|
||||
|
||||
// AUInt32.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) Get() uint32 { return atomic.LoadUint32(&u.value) }
|
||||
|
||||
// AUInt32.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) Set(val uint32) { atomic.StoreUint32(&u.value, val) }
|
||||
|
||||
// AUInt32.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) Swap(new uint32) uint32 { return atomic.SwapUint32(&u.value, new) }
|
||||
|
||||
// AUInt32.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) Add(dlt uint32) uint32 { return atomic.AddUint32(&u.value, dlt) }
|
||||
|
||||
// AUInt32.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) Sub(dlt uint32) uint32 { return atomic.AddUint32(&u.value, ^uint32(dlt-1)) }
|
||||
|
||||
// AUInt32.Inc
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) Inc() uint32 { return u.Add(1) }
|
||||
|
||||
// AUInt32.Dec
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) Dec() uint32 { return u.Add(^uint32(0)) }
|
||||
|
||||
// AUInt32.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt32) CAS(old, new uint32) bool { return atomic.CompareAndSwapUint32(&u.value, old, new) }
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,121 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// AUInt64
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
//
|
||||
AUInt64 struct {
|
||||
value uint64
|
||||
}
|
||||
)
|
||||
|
||||
// NewAUInt64
|
||||
// Desc: Función constructor para AUInt64
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewAUInt64(val uint64) *AUInt64 { return &AUInt64{value: val} }
|
||||
|
||||
// AUInt64.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) Get() uint64 { return atomic.LoadUint64(&u.value) }
|
||||
|
||||
// AUInt64.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) Set(val uint64) { atomic.StoreUint64(&u.value, val) }
|
||||
|
||||
// AUInt64.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) Swap(new uint64) uint64 { return atomic.SwapUint64(&u.value, new) }
|
||||
|
||||
// AUInt64.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) Add(dlt uint64) uint64 { return atomic.AddUint64(&u.value, dlt) }
|
||||
|
||||
// AUInt64.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) Sub(dlt uint64) uint64 { return atomic.AddUint64(&u.value, ^uint64(dlt-1)) }
|
||||
|
||||
// AUInt64.Inc
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) Inc() uint64 { return u.Add(1) }
|
||||
|
||||
// AUInt64.Dec
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) Dec() uint64 { return u.Add(^uint64(0)) }
|
||||
|
||||
// AUInt64.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt64) CAS(old, new uint64) bool { return atomic.CompareAndSwapUint64(&u.value, old, new) }
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,64 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// +build 386 arm mips mipsle
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type AInt struct{ value int32 }
|
||||
|
||||
func NewAInt(v int) *AInt { return &AInt{value: int32(v)} }
|
||||
|
||||
func (u *AInt) Get() int { return int(atomic.LoadInt32(&u.value)) }
|
||||
func (u *AInt) Set(v int) { atomic.StoreInt32(&u.value, int32(v)) }
|
||||
func (u *AInt) Swap(new int) int { return int(atomic.SwapInt32(&u.value, int32(new))) }
|
||||
|
||||
func (u *AInt) Add(dlt int) int { return int(atomic.AddInt32(&u.value, int32(dlt))) }
|
||||
func (u *AInt) Sub(dlt int) int { return int(atomic.AddInt32(&u.value, -dlt)) }
|
||||
func (u *AInt) Inc() int { return u.Add(1) }
|
||||
func (u *AInt) Dec() int { return u.Add(-1) }
|
||||
|
||||
func (u *AInt) CAS(old, new int) bool {
|
||||
return atomic.CompareAndSwapInt32(&u.value, int32(old), int32(new))
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,64 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// +build 386 arm mips mipsle
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type AUInt struct{ value uint32 }
|
||||
|
||||
func NewAUint(v uint) *AUInt { return &AUInt{value: uint32(v)} }
|
||||
|
||||
func (u *AUInt) Get() uint { return uint(atomic.LoadUint32(&u.value)) }
|
||||
func (u *AUInt) Set(v uint) { atomic.StoreUint32(&u.value, uint32(v)) }
|
||||
func (u *AUInt) Swap(new uint) uint { return uint(atomic.SwapUint32(&u.value, uint32(new))) }
|
||||
|
||||
func (u *AUInt) Add(dlt uint) uint { return uint(atomic.AddUint32(&u.value, uint32(dlt))) }
|
||||
func (u *AUInt) Sub(dlt uint) uint { return uint(atomic.AddUint32(&u.value, ^uint32(uint32(dlt)-1))) }
|
||||
func (u *AUInt) Inc() uint { return u.Add(1) }
|
||||
func (u *AUInt) Dec() uint { return u.Add(uint(^uint32(0))) }
|
||||
|
||||
func (u *AUInt) CAS(old, new uint) bool {
|
||||
return atomic.CompareAndSwapUint32(&u.value, uint32(old), uint32(new))
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,124 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// +build amd64 arm64 ppc64 ppc64le mips64 mips64le s390x
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// AInt
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
AInt struct {
|
||||
value int64
|
||||
}
|
||||
)
|
||||
|
||||
// NewAInt
|
||||
// Desc: Función constructor para AInt
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewAInt(val int) *AInt { return &AInt{value: int64(val)} }
|
||||
|
||||
// AInt.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) Get() int { return int(atomic.LoadInt64(&u.value)) }
|
||||
|
||||
// AInt.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) Set(v int) { atomic.StoreInt64(&u.value, int64(v)) }
|
||||
|
||||
// AInt.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) Swap(new int) int { return int(atomic.SwapInt64(&u.value, int64(new))) }
|
||||
|
||||
// AInt.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) Add(dlt int) int { return int(atomic.AddInt64(&u.value, int64(dlt))) }
|
||||
|
||||
// AInt.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) Sub(dlt int) int { return int(atomic.AddInt64(&u.value, int64(-dlt))) }
|
||||
|
||||
// AInt.Inc
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) Inc() int { return u.Add(1) }
|
||||
|
||||
// AInt.Dec
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) Dec() int { return u.Add(-1) }
|
||||
|
||||
// AInt.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AInt) CAS(old, new int) bool {
|
||||
return atomic.CompareAndSwapInt64(&u.value, int64(old), int64(new))
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -0,0 +1,124 @@
|
||||
//
|
||||
// Feb21
|
||||
//
|
||||
// GO Active Thing
|
||||
// Framework
|
||||
//
|
||||
// http://activething.com/dev/goat
|
||||
//
|
||||
// Dev : Juan V.Navarro
|
||||
// Email: juanvnl@activething.com
|
||||
// Date : 16/02/2021
|
||||
//
|
||||
// Copyright 2021 the GOAT Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
// +build amd64 arm64 ppc64 ppc64le mips64 mips64le s390x
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// AUInt
|
||||
// Type: Struct
|
||||
// Desc:
|
||||
//
|
||||
AUInt struct {
|
||||
value uint64
|
||||
}
|
||||
)
|
||||
|
||||
// NewAInt
|
||||
// Desc: Función constructor para AUInt
|
||||
//
|
||||
// Prms: val, valor inicial
|
||||
// Rets: Puntero al nuevo objeto creado.
|
||||
//
|
||||
func NewAUint(val int64) *AUInt { return &AUInt{value: uint64(val)} }
|
||||
|
||||
// AUInt.Get
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) Get() uint { return uint(atomic.LoadUint64(&u.value)) }
|
||||
|
||||
// AUInt.Set
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) Set(val uint) { atomic.StoreUint64(&u.value, uint64(val)) }
|
||||
|
||||
// AUInt.Swap
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) Swap(new uint) uint { return uint(atomic.SwapUint64(&u.value, uint64(new))) }
|
||||
|
||||
// AUInt.Add
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) Add(dlt uint) uint { return uint(atomic.AddUint64(&u.value, uint64(dlt))) }
|
||||
|
||||
// AUInt.Sub
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) Sub(dlt uint) uint { return uint(atomic.AddUint64(&u.value, ^uint64(dlt-1))) }
|
||||
|
||||
// AUInt.Inc
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) Inc() uint { return u.Add(1) }
|
||||
|
||||
// AUInt.Dec
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) Dec() uint { return uint(^uint64(0)) }
|
||||
|
||||
// AUInt.CAS
|
||||
// Desc:
|
||||
// Prms:
|
||||
// Rets:
|
||||
//
|
||||
func (u *AUInt) CAS(old, new uint) bool {
|
||||
return atomic.CompareAndSwapUint64(&u.value, uint64(old), uint64(new))
|
||||
}
|
||||
|
||||
/*
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
I HAVE NO DESIRE TO WALK ON WATER," SAID SIDDHARTA.
|
||||
"LET THE OLD SHRAMANAS SATISFY THEMSELVES WITH SUCH SKILLS.
|
||||
|
||||
SIDDHARTA
|
||||
- HERMANN HESSE -
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
*/
|
||||
@ -1,69 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name pool_ops.go
|
||||
// Created by DEV
|
||||
// Modified 17/01/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package syncs
|
||||
|
||||
import (
|
||||
"opts"
|
||||
"sync/atomic"
|
||||
)
|
||||
|
||||
func PoolWithNew[T any](nfn func() *T) opts.GOptionFnc[Pool[T]] {
|
||||
return func(p *Pool[T]) {
|
||||
p.createFn = nfn
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func PoolWithCap[T any](cap int32) opts.GOptionFnc[Pool[T]] {
|
||||
return func(p *Pool[T]) {
|
||||
atomic.StoreInt32(&p.cap, cap)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func PoolWithLen[T any](len int32) opts.GOptionFnc[Pool[T]] {
|
||||
return func(p *Pool[T]) {
|
||||
if p.createFn == nil {
|
||||
return
|
||||
}
|
||||
c := p.Cap()
|
||||
if c != -1 && len > c {
|
||||
len = c
|
||||
}
|
||||
for i := int32(0); i < len; i++ {
|
||||
p.Put(p.createFn())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func PoolWithSet[T any](els ...*T) opts.GOptionFnc[Pool[T]] {
|
||||
return func(p *Pool[T]) {
|
||||
for _, e := range els {
|
||||
if e != nil {
|
||||
p.Put(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name g_queue.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package queue
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"syncs"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
GQueue [T any]struct {
|
||||
locker syncs.LockerRW
|
||||
elems []T
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
|
||||
func NewGQueue [T any](safe bool) *GQueue[T] {
|
||||
var lc syncs.LockerRW
|
||||
if safe {
|
||||
lc = &sync.RWMutex{}
|
||||
}
|
||||
return &GQueue[T]{ locker : lc }
|
||||
}
|
||||
|
||||
|
||||
func (q *GQueue[T]) Len () (l int) {
|
||||
q.locker.RLock()
|
||||
l = len(q.elems)
|
||||
q.locker.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
func (q *GQueue[T]) Push(ele T) {
|
||||
q.locker.Lock()
|
||||
q.elems = append(q.elems,ele)
|
||||
q.locker.Unlock()
|
||||
}
|
||||
|
||||
|
||||
func (q *GQueue[T]) Pop() (e T) {
|
||||
q.locker.Lock()
|
||||
if q.Len() > 0 {
|
||||
e = q.elems[0]
|
||||
q.elems = q.elems[1:]
|
||||
}
|
||||
q.locker.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
func (q *GQueue[T]) Clear (onClearFnc func(ele T)) {
|
||||
q.locker.Lock()
|
||||
if onClearFnc != nil {
|
||||
for _,e := range q.elems {
|
||||
onClearFnc(e)
|
||||
}
|
||||
}
|
||||
q.elems = q.elems[:0]
|
||||
q.locker.Unlock()
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name aggregator.go
|
||||
// Created by DEV
|
||||
// Modified 25/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
Aggregators []EntryFnc
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
func (a Aggregators) Apply (entry *Entry) *Entry{
|
||||
for _,f := range a {
|
||||
f(entry)
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
|
||||
func (a Aggregators) Append (entryFn ... EntryFnc) Aggregators {
|
||||
return append(a,entryFn...) }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,90 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name hecate.go
|
||||
// Created by DEV
|
||||
// Modified 25/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
import (
|
||||
"errs"
|
||||
"syncs/queue"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
ALogger struct {
|
||||
loggerLevel
|
||||
Aggregators
|
||||
Filters
|
||||
|
||||
scopes Scopes
|
||||
|
||||
queue queue.GQueue[*Entry]
|
||||
|
||||
state State
|
||||
count int
|
||||
|
||||
logErrors bool
|
||||
errors errs.ErrorList
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ManagerFnc func(manager *ALogger)
|
||||
)
|
||||
|
||||
|
||||
func NewALogger(name string, level Level, options ...ManagerFnc) *ALogger {
|
||||
m := &ALogger{
|
||||
loggerLevel : *newLoggerLevel(name,level),
|
||||
Filters : *NewFilters(),
|
||||
|
||||
state : StateCreated,
|
||||
logErrors : true,
|
||||
}
|
||||
m.logFn = m.log
|
||||
for o := range options {
|
||||
o(m)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
|
||||
func (l *ALogger) Start (all bool) error {
|
||||
l.mux.Lock()
|
||||
if l.state == StateStarted {
|
||||
l.mux.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
l.errors = l.errors[:0]
|
||||
l.state = StateStarted
|
||||
|
||||
if !all {
|
||||
l.mux.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
for _,cl := range l.cores {
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name appender.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
Appender interface {
|
||||
|
||||
Append (entry *Entry) error
|
||||
}
|
||||
|
||||
AppendFnc func (entry *Entry) error
|
||||
)
|
||||
|
||||
|
||||
func (f AppendFnc) Append (entry *Entry) error {
|
||||
return f(entry) }
|
||||
|
||||
@ -0,0 +1,136 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name entry.go
|
||||
// Created by DEV
|
||||
// Modified 23/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
import (
|
||||
"atypes/slices"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
|
||||
Entry struct {
|
||||
Logger Logger
|
||||
|
||||
Id uint64
|
||||
Scope string
|
||||
Scopes [][]byte
|
||||
Level Level
|
||||
|
||||
Message string
|
||||
Date time.Time
|
||||
|
||||
Error error
|
||||
|
||||
Data any
|
||||
|
||||
excludes slices.Strings
|
||||
}
|
||||
|
||||
|
||||
|
||||
EntryFnc func (entry *Entry)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func AcquireEntry (logger Logger, level Level, message string, err error, options ...EntryFnc) *Entry {
|
||||
return g.entryPool.Get().init(logger,level,message,err,options...) }
|
||||
|
||||
func ReleaseEntry (entry *Entry) {
|
||||
g.entryPool.Put(entry.reset()) }
|
||||
|
||||
|
||||
|
||||
func NewEntry (logger Logger, level Level, message string, err error, options ...EntryFnc) *Entry {
|
||||
return newEntry().init(logger,level,message,err,options...) }
|
||||
|
||||
func newEntry () *Entry {
|
||||
return &Entry{} }
|
||||
|
||||
func (e *Entry) init (logger Logger, level Level, message string, err error, options ...EntryFnc) *Entry {
|
||||
e.Id = g.idGen.Inc()
|
||||
e.Logger = logger
|
||||
e.Level = level
|
||||
e.Error = err
|
||||
e.Message= message
|
||||
e.Date = time.Now()
|
||||
for _,o := range options {
|
||||
o(e)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
func (e *Entry) reset () *Entry {
|
||||
if e == nil {
|
||||
return nil
|
||||
}
|
||||
e.Logger = nil
|
||||
e.excludes = e.excludes.Reset()
|
||||
for _,s := range e.Scopes {
|
||||
s = s[:0]
|
||||
}
|
||||
e.Scopes = e.Scopes[:0]
|
||||
e.Error = nil
|
||||
e.Data = nil
|
||||
e.Message= ""
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
|
||||
func (e *Entry) IsExcluded (value string) bool {
|
||||
return e.excludes.Has(value) }
|
||||
|
||||
|
||||
func (e *Entry) Clone() *Entry {
|
||||
n := *e
|
||||
/*
|
||||
l:=len(e.Fields)
|
||||
if l > 0 {
|
||||
n.Fields = make(vals.Fields,len(e.Fields))
|
||||
for i:=0; i<l; i++ {
|
||||
n.Fields[i]=e.Fields[i]
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
return &n
|
||||
}
|
||||
|
||||
|
||||
func EntryWithExclude (exclude ... string) EntryFnc {
|
||||
return func(e *Entry) {
|
||||
for _, ex := range exclude {
|
||||
if len(ex) > 0 {
|
||||
e.excludes = e.excludes.Append(ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name entry_logger.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
EntryLogger interface {
|
||||
|
||||
Log (entry *Entry) error
|
||||
}
|
||||
|
||||
|
||||
LogEntryFnc func(entry *Entry) error
|
||||
)
|
||||
|
||||
|
||||
func (f LogEntryFnc) Log(entry *Entry) error {
|
||||
return f(entry) }
|
||||
|
||||
@ -0,0 +1,105 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name entry_filter.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
import (
|
||||
"bins/tokens"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
Filter struct {
|
||||
name string
|
||||
active bool
|
||||
filterFnc FilterFnc
|
||||
}
|
||||
|
||||
|
||||
FilterFnc func (entry *Entry) bool
|
||||
|
||||
|
||||
)
|
||||
|
||||
func NewFilter(name string, fnc FilterFnc) *Filter {
|
||||
if fnc == nil {
|
||||
fnc = NopFilterTrue
|
||||
}
|
||||
return &Filter{
|
||||
name : name,
|
||||
active : true,
|
||||
filterFnc : fnc,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func NewFilterLevel (name string, level Level) *Filter {
|
||||
if len(name) == 0 {
|
||||
name = filterLevelName
|
||||
}
|
||||
l := level
|
||||
return &Filter{
|
||||
name : name,
|
||||
active : true,
|
||||
filterFnc: func(e *Entry) bool {
|
||||
return l.Has(e.Level)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewFilterScope (name string, topic string) *Filter {
|
||||
if len(name) == 0 {
|
||||
name = filterScopeName
|
||||
}
|
||||
tp := *g.tokenizer.NewTopic([]byte(strings.ToLower(topic)),tokens.TokenKindAll)
|
||||
return &Filter{
|
||||
name : name,
|
||||
active : true,
|
||||
filterFnc: func(e *Entry) bool {
|
||||
return tp.Match(e.Scopes)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func (f *Filter) Name () string {
|
||||
return f.name }
|
||||
|
||||
func (f *Filter) IsActive () bool {
|
||||
return f.active }
|
||||
|
||||
func (f *Filter) SetActive (enable bool) {
|
||||
f.active = enable }
|
||||
|
||||
func (f *Filter) Filter (entry *Entry) bool {
|
||||
return f.filterFnc(entry) }
|
||||
|
||||
|
||||
|
||||
func NopFilterTrue (_ *Entry) bool {
|
||||
return true }
|
||||
|
||||
|
||||
func NopFilterFalse(_ *Entry) bool {
|
||||
return false }
|
||||
@ -0,0 +1,116 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name filters.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
type (
|
||||
|
||||
Filters struct {
|
||||
allows []*Filter
|
||||
denies []*Filter
|
||||
}
|
||||
|
||||
|
||||
FiltersFnc func(f *Filters)
|
||||
)
|
||||
|
||||
|
||||
func NewFilters (options ...FiltersFnc) *Filters {
|
||||
f := &Filters {
|
||||
}
|
||||
for _,o := range options {
|
||||
o(f)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *Filters) AddFilterAllowed(filter *Filter) {
|
||||
f.add(filter,&f.allows) }
|
||||
|
||||
func (f *Filters) AddFilterDenied (filter *Filter) {
|
||||
f.add(filter,&f.denies) }
|
||||
|
||||
func (f *Filters) DelFilterAllowed(name string) {
|
||||
f.del(name,&f.allows) }
|
||||
|
||||
func (f *Filters) DelFilterDenied (name string) {
|
||||
f.del(name,&f.denies) }
|
||||
|
||||
|
||||
|
||||
func (f *Filters) Filter (entry *Entry) bool {
|
||||
|
||||
if len(f.allows) > 0 {
|
||||
p := false
|
||||
for _,fi := range f.allows {
|
||||
if fi.IsActive() {
|
||||
if p = fi.Filter(entry); p {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if !p {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
for _,fi := range f.denies {
|
||||
if fi.IsActive() {
|
||||
if fi.Filter(entry) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (f *Filters) add (ft *Filter, ls *[]*Filter) {
|
||||
if p := filterPos(*ls, ft.name); p != -1 {
|
||||
(*ls)[p]= ft
|
||||
return
|
||||
}
|
||||
*ls = append(*ls, ft)
|
||||
}
|
||||
|
||||
func (f *Filters) del (name string, ls *[]*Filter) {
|
||||
if p := filterPos(*ls,name); p != -1 {
|
||||
*ls = append((*ls)[:p],(*ls)[p+1:]...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func filterPos (list []*Filter, name string) int {
|
||||
for i,f := range list {
|
||||
if f.name == name {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
module hecate
|
||||
|
||||
go 1.22
|
||||
@ -0,0 +1,52 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name logger_core.go
|
||||
// Created by DEV
|
||||
// Modified 25/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
import "errs"
|
||||
|
||||
type (
|
||||
|
||||
LoggerCore struct {
|
||||
loggerLevel
|
||||
Filters
|
||||
Aggregators
|
||||
Appender
|
||||
|
||||
state State
|
||||
count int
|
||||
|
||||
errors errs.ErrorList
|
||||
|
||||
}
|
||||
|
||||
|
||||
LoggerCoreFnc func(l *LoggerCore)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
func NewLoggerCore (name string, level Level, options ...LoggerCoreFnc) *LoggerCore {
|
||||
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name logger_level.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
import "sync"
|
||||
|
||||
type (
|
||||
|
||||
|
||||
loggerLevel struct {
|
||||
mux sync.RWMutex
|
||||
name string
|
||||
level Level
|
||||
logFn LogFnc
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
|
||||
func newLoggerLevel (name string, level Level) *loggerLevel {
|
||||
return &loggerLevel{
|
||||
name : name,
|
||||
level: level } }
|
||||
|
||||
|
||||
func (l *loggerLevel) Name () string {
|
||||
return l.name }
|
||||
|
||||
func (l *loggerLevel) Level() (lv Level) {
|
||||
l.mux.RLock()
|
||||
lv = l.level
|
||||
l.mux.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (l *loggerLevel) SetLevel (level Level) {
|
||||
l.mux.Lock()
|
||||
l.level = level
|
||||
l.mux.Unlock()
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (l *loggerLevel) Fatal (msg string, err error, ops ...EntryFnc){
|
||||
l.logFn(LevelFatal,msg,err,ops ...) }
|
||||
|
||||
|
||||
func (l *loggerLevel) Error (msg string, err error, ops ...EntryFnc){
|
||||
l.logFn(LevelError,msg,err,ops ...) }
|
||||
|
||||
|
||||
func (l *loggerLevel) Warn (msg string, ops ...EntryFnc){
|
||||
l.logFn(LevelWarn,msg,nil,ops ...) }
|
||||
|
||||
|
||||
func (l *loggerLevel) Info (msg string, ops ...EntryFnc){
|
||||
l.logFn(LevelInfo,msg,nil,ops...) }
|
||||
|
||||
|
||||
func (l *loggerLevel) Debug (msg string, ops ...EntryFnc){
|
||||
l.logFn(LevelDebug,msg,nil,ops...) }
|
||||
|
||||
|
||||
func (l *loggerLevel) Data (msg string, data any, ops ...EntryFnc){
|
||||
l.logFn(LevelData,msg,nil,func (e *Entry) {
|
||||
e.Data = data
|
||||
for _,o := range ops {
|
||||
o(e)
|
||||
}
|
||||
}) }
|
||||
|
||||
|
||||
@ -0,0 +1,192 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name scope.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
|
||||
Scope struct {
|
||||
loggerLevel
|
||||
Aggregators
|
||||
|
||||
path string
|
||||
nodes [][]byte
|
||||
|
||||
mode ScopeMode
|
||||
parent Loggable
|
||||
scopes Scopes
|
||||
}
|
||||
|
||||
ScopeFnc func (s *Scope)
|
||||
|
||||
)
|
||||
|
||||
|
||||
func newScope(name string, level Level, parent Loggable, path string, nodes [][]byte, options []ScopeFnc) *Scope {
|
||||
if path != "" {
|
||||
path = fmt.Sprintf("%s%c%s",path,G.ScopeSep,name)
|
||||
} else {
|
||||
path = name
|
||||
}
|
||||
sc := &Scope {
|
||||
loggerLevel: *newLoggerLevel(name,level),
|
||||
parent: parent,
|
||||
nodes : append(nodes,[]byte(name)),
|
||||
path : path,
|
||||
}
|
||||
sc.logFn = sc.log
|
||||
for _,o := range options {
|
||||
o(sc)
|
||||
}
|
||||
return sc
|
||||
}
|
||||
|
||||
|
||||
func (s *Scope) Nodes() [][]byte {
|
||||
return s.nodes }
|
||||
|
||||
func (s *Scope) Path () string {
|
||||
return s.path }
|
||||
|
||||
func (s *Scope) Mode () (m ScopeMode) {
|
||||
s.mux.RLock()
|
||||
m = s.mode
|
||||
s.mux.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (s *Scope) SetMode (mode ScopeMode) {
|
||||
if !mode.isValid() {
|
||||
panic(G.ErrInvalidScopeMode)
|
||||
}
|
||||
s.mux.Lock()
|
||||
s.mode = mode
|
||||
s.mux.Unlock()
|
||||
}
|
||||
|
||||
func (s *Scope) GetScope (name string) *Scope {
|
||||
return s.getScope(strings.Split(strings.ToLower(name),g.scopeSepStr)) }
|
||||
|
||||
func (s *Scope) getScope (nodes []string)( sc *Scope) {
|
||||
s.mux.RLock()
|
||||
if sc = s.scopes.getScope(nodes[0]); sc != nil {
|
||||
if len(nodes) > 1 {
|
||||
sc = sc.getScope(nodes[:1])
|
||||
}
|
||||
}
|
||||
s.mux.RUnlock()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
func (s *Scope) NewScope (path string, options ...ScopeFnc) (*Scope,error) {
|
||||
return s.newScope(strings.Split(strings.ToLower(path),g.scopeSepStr),options) }
|
||||
|
||||
func (s *Scope) newScope (path []string, options []ScopeFnc) (sc *Scope, er error) {
|
||||
s.mux.Lock()
|
||||
if sc = s.scopes.getScope(path[0]); sc == nil {
|
||||
sc = newScope(path[0], s.level, s, s.path, s.nodes,options)
|
||||
s.scopes = append(s.scopes, sc)
|
||||
if len(path) == 1 {
|
||||
s.mux.Unlock()
|
||||
return
|
||||
}
|
||||
} else if len(path) == 1 {
|
||||
s.mux.Unlock()
|
||||
return nil,G.ErrDuplicatedScope
|
||||
}
|
||||
sc,er = sc.newScope(path[1:],options)
|
||||
s.mux.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func (s *Scope) Log(ent *Entry) error {
|
||||
s.mux.Lock()
|
||||
if s.mode & ScopeFilter != 0 && !s.level.Has(ent.Level) {
|
||||
s.mux.Unlock()
|
||||
return nil
|
||||
}
|
||||
if s.mode.IsCascade() {
|
||||
s.Apply(ent)
|
||||
}
|
||||
s.mux.Unlock()
|
||||
return s.parent.Log(ent)
|
||||
}
|
||||
|
||||
|
||||
func (s *Scope) log(lvl Level, msg string, err error,ops ...EntryFnc){
|
||||
s.mux.Lock()
|
||||
if !s.level.Has(lvl) {
|
||||
s.mux.Unlock()
|
||||
return
|
||||
}
|
||||
en := s.Apply(AcquireEntry(nil,lvl,msg,err,ops...))
|
||||
en.Scope = s.path
|
||||
en.Scopes= s.nodes
|
||||
s.mux.Unlock()
|
||||
|
||||
s.parent.Log(en)
|
||||
ReleaseEntry(en)
|
||||
|
||||
}
|
||||
|
||||
|
||||
func ScopeWithMode (mode ScopeMode) ScopeFnc {
|
||||
return func(s *Scope) {
|
||||
if !mode.isValid() {
|
||||
panic(G.ErrInvalidScopeMode)
|
||||
}
|
||||
if mode == ScopeDirect {
|
||||
s.mode = ScopeDirect
|
||||
return
|
||||
}
|
||||
s.mode |= mode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func ScopeWithLevel (level Level) ScopeFnc {
|
||||
return func(s *Scope) {
|
||||
if !level.isValid() {
|
||||
panic(G.ErrInvalidLevel)
|
||||
}
|
||||
s.level = level
|
||||
}
|
||||
}
|
||||
|
||||
func ScopeWithAggregator (aggregator ...EntryFnc) ScopeFnc {
|
||||
return func(s *Scope) {
|
||||
for _,a := range aggregator {
|
||||
s.Aggregators = s.Aggregators.Append(a)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name scope.go
|
||||
// Created by DEV
|
||||
// Modified 24/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
const (
|
||||
|
||||
ScopeCascade ScopeMode = 1 << iota
|
||||
ScopeFilter
|
||||
|
||||
ScopeDirect = 0
|
||||
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
ScopeMode uint8
|
||||
)
|
||||
|
||||
|
||||
func (m ScopeMode) isValid () bool {
|
||||
return m <= ScopeFilter }
|
||||
|
||||
|
||||
func (m ScopeMode) IsDirect() bool {
|
||||
return m == ScopeDirect }
|
||||
|
||||
func (m ScopeMode) IsCascade() bool {
|
||||
return m & ScopeCascade != 0 }
|
||||
|
||||
func (m ScopeMode) IsFilter () bool {
|
||||
return m & ScopeFilter != 0 }
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project active2
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name scopes.go
|
||||
// Created by DEV
|
||||
// Modified 25/04/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package logs
|
||||
|
||||
|
||||
|
||||
type (
|
||||
|
||||
Scopes []*Scope
|
||||
)
|
||||
|
||||
|
||||
func (s Scopes) getScope (name string) *Scope {
|
||||
if ps := s.find(name); ps != -1 {
|
||||
return s[ps]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func (s Scopes) find (name string) int {
|
||||
for i,e := range s {
|
||||
if e.name == name {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
|
||||
func (s Scopes) walk(walkfn func(sc *Scope) bool) bool {
|
||||
ex := true
|
||||
for i:=0; i<len(s) && ex; i++ {
|
||||
e := s[i]
|
||||
e.mux.Lock()
|
||||
if ex = walkfn(e); ex {
|
||||
ex = e.scopes.walk(walkfn)
|
||||
}
|
||||
e.mux.Unlock()
|
||||
}
|
||||
return ex
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
module logs
|
||||
|
||||
go 1.22
|
||||
@ -1,7 +0,0 @@
|
||||
module packs
|
||||
|
||||
|
||||
go 1.22
|
||||
|
||||
|
||||
|
||||
@ -1,80 +0,0 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name builder_list.go
|
||||
// Created by DEV
|
||||
// Modified 06/02/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package pjson
|
||||
|
||||
import (
|
||||
"packs"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (p *JSONPacker) ItemAny (value any, flags packs.Flags) { p.addItem(func(){ p.PackAny(value,flags) }) }
|
||||
|
||||
|
||||
func (p *JSONPacker) ItemRaw (value []byte, flags packs.Flags) { p.addItem(func() { p.PackRaw(value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemBinary (value []byte, flags packs.Flags) { p.addItem(func (){ p.PackBinary(value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemString (value string, flags packs.Flags) { p.addItem(func (){ p.PackString(value,flags) }) }
|
||||
|
||||
|
||||
func (p *JSONPacker) ItemBool (value bool, flags packs.Flags) { p.addItem(func (){ p.PackBool(value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemInt8 (value int8 , flags packs.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemInt16 (value int16, flags packs.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemInt32 (value int32, flags packs.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemInt64 (value int64, flags packs.Flags) { p.addItem(func (){ packInt(p.state,value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemUInt8 (value uint8 , flags packs.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemUInt16 (value uint16, flags packs.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemUInt32 (value uint32, flags packs.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemUInt64 (value uint64, flags packs.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemFloat32 (value float32, flags packs.Flags){ p.addItem(func (){ packFloatString(p.state,float64(value),flags,32)})}
|
||||
func (p *JSONPacker) ItemFloat64 (value float64, flags packs.Flags){ p.addItem(func (){ packFloatString(p.state,value,flags,64) })}
|
||||
|
||||
func (p *JSONPacker) ItemDate (value time.Time, flags packs.Flags) { p.addItem(func(){ packDate(p.state,value,flags); p.state.Inc() })}
|
||||
|
||||
|
||||
func (p *JSONPacker) ItemList (builder func(packs.ListPackBuilder, packs.Flags), flags packs.Flags) {
|
||||
p.addItem(func(){ p.PackList(builder,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemMap (builder func(packs.MapPackBuilder, packs.Flags), flags packs.Flags) {
|
||||
p.addItem(func(){ p.PackMap(builder,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemObject(builder func(packs.ObjectPackBuilder, packs.Flags), flags packs.Flags) {
|
||||
p.addItem(func(){ p.PackObject(builder,flags) }) }
|
||||
|
||||
|
||||
|
||||
func (p *JSONPacker) addItem (caller func()) {
|
||||
if p.state.Count() > 0 {
|
||||
p.state.WriteByte(',')
|
||||
}
|
||||
caller()
|
||||
if p.state != nil {
|
||||
p.state.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
module proteus
|
||||
|
||||
|
||||
go 1.22
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,80 @@
|
||||
// ------------------------------------------------------------------------
|
||||
// Project atila
|
||||
// Active Thing (activething.com) git.activething.com/go
|
||||
//
|
||||
// File name builder_list.go
|
||||
// Created by DEV
|
||||
// Modified 06/02/2024
|
||||
//
|
||||
// Copyright 2024 activething.com
|
||||
// ------------------------------------------------------------------------
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
package pjson
|
||||
|
||||
import (
|
||||
"packs"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (p *JSONPacker) ItemAny (value any, flags proteus.Flags) { p.addItem(func(){ p.PackAny(value,flags) }) }
|
||||
|
||||
|
||||
func (p *JSONPacker) ItemRaw (value []byte, flags proteus.Flags) { p.addItem(func() { p.PackRaw(value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemBinary (value []byte, flags proteus.Flags) { p.addItem(func (){ p.PackBinary(value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemString (value string, flags proteus.Flags) { p.addItem(func (){ p.PackString(value,flags) }) }
|
||||
|
||||
|
||||
func (p *JSONPacker) ItemBool (value bool, flags proteus.Flags) { p.addItem(func (){ p.PackBool(value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemInt8 (value int8 , flags proteus.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemInt16 (value int16, flags proteus.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemInt32 (value int32, flags proteus.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemInt64 (value int64, flags proteus.Flags) { p.addItem(func (){ packInt(p.state,value,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemUInt8 (value uint8 , flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemUInt16 (value uint16, flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemUInt32 (value uint32, flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
func (p *JSONPacker) ItemUInt64 (value uint64, flags proteus.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemFloat32 (value float32, flags proteus.Flags){ p.addItem(func (){ packFloatString(p.state,float64(value),flags,32)})}
|
||||
func (p *JSONPacker) ItemFloat64 (value float64, flags proteus.Flags){ p.addItem(func (){ packFloatString(p.state,value,flags,64) })}
|
||||
|
||||
func (p *JSONPacker) ItemDate (value time.Time, flags proteus.Flags) { p.addItem(func(){ packDate(p.state,value,flags); p.state.Inc() })}
|
||||
|
||||
|
||||
func (p *JSONPacker) ItemList (builder func(proteus.ListPackBuilder, proteus.Flags), flags proteus.Flags) {
|
||||
p.addItem(func(){ p.PackList(builder,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemMap (builder func(proteus.MapPackBuilder, proteus.Flags), flags proteus.Flags) {
|
||||
p.addItem(func(){ p.PackMap(builder,flags) }) }
|
||||
|
||||
func (p *JSONPacker) ItemObject(builder func(proteus.ObjectPackBuilder, proteus.Flags), flags proteus.Flags) {
|
||||
p.addItem(func(){ p.PackObject(builder,flags) }) }
|
||||
|
||||
|
||||
|
||||
func (p *JSONPacker) addItem (caller func()) {
|
||||
if p.state.Count() > 0 {
|
||||
p.state.WriteByte(',')
|
||||
}
|
||||
caller()
|
||||
if p.state != nil {
|
||||
p.state.Inc()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in new issue