diff --git a/hecate/active.go b/alogs/active.go similarity index 99% rename from hecate/active.go rename to alogs/active.go index 46f59b3..1e4c866 100644 --- a/hecate/active.go +++ b/alogs/active.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs import ( "atypes/astrings" diff --git a/hecate/ejson/encoder.go b/alogs/ejson/encoder.go similarity index 93% rename from hecate/ejson/encoder.go rename to alogs/ejson/encoder.go index 1c39b09..8b8d0a2 100644 --- a/hecate/ejson/encoder.go +++ b/alogs/ejson/encoder.go @@ -24,8 +24,8 @@ package ejson import ( - "hecate" - "proteus/pjson" + "alogs" + "apacks/pjson" "results" ) @@ -38,5 +38,5 @@ type ( -func EncodeEntry (entry *hecate.Entry) results.Bytes { +func EncodeEntry (entry *alogs.Entry) results.Bytes { return pjson.Pack(entry) } diff --git a/hecate/entry.go b/alogs/entry.go similarity index 95% rename from hecate/entry.go rename to alogs/entry.go index 752cc74..078f338 100644 --- a/hecate/entry.go +++ b/alogs/entry.go @@ -21,11 +21,10 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs import ( "atypes/slices" - "proteus" "time" ) @@ -118,8 +117,8 @@ func (e *Entry) Clone() *Entry { } -func (e *Entry) BuildPack(packer proteus.ValuePacker) error { - packer.PackObject(func (b proteus.ObjectPackBuilder, _ proteus.Flags){ +func (e *Entry) BuildPack(packer apacks.ValuePacker) error { + packer.PackObject(func (b apacks.ObjectPackBuilder, _ apacks.Flags){ b.FieldUInt64("id",e.Id,0) b.FieldDate("date",e.Date,0) },0) diff --git a/hecate/entry_appender.go b/alogs/entry_appender.go similarity index 97% rename from hecate/entry_appender.go rename to alogs/entry_appender.go index 8793b87..519fdb5 100644 --- a/hecate/entry_appender.go +++ b/alogs/entry_appender.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/hecate/entry_encoder.go b/alogs/entry_encoder.go similarity index 98% rename from hecate/entry_encoder.go rename to alogs/entry_encoder.go index 5a289e9..3aed378 100644 --- a/hecate/entry_encoder.go +++ b/alogs/entry_encoder.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/hecate/entry_extender.go b/alogs/entry_extender.go similarity index 97% rename from hecate/entry_extender.go rename to alogs/entry_extender.go index ce6254a..52f42b3 100644 --- a/hecate/entry_extender.go +++ b/alogs/entry_extender.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/hecate/entry_extenders.go b/alogs/entry_extenders.go similarity index 98% rename from hecate/entry_extenders.go rename to alogs/entry_extenders.go index 5ec286f..61960b6 100644 --- a/hecate/entry_extenders.go +++ b/alogs/entry_extenders.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/hecate/entry_filter.go b/alogs/entry_filter.go similarity index 98% rename from hecate/entry_filter.go rename to alogs/entry_filter.go index 361f0eb..bb1e679 100644 --- a/hecate/entry_filter.go +++ b/alogs/entry_filter.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs import ( "bins/tokens" diff --git a/hecate/entry_filters.go b/alogs/entry_filters.go similarity index 99% rename from hecate/entry_filters.go rename to alogs/entry_filters.go index 7f830e8..a0e7f19 100644 --- a/hecate/entry_filters.go +++ b/alogs/entry_filters.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/hecate/entry_logger.go b/alogs/entry_logger.go similarity index 98% rename from hecate/entry_logger.go rename to alogs/entry_logger.go index a855cd3..af3b11b 100644 --- a/hecate/entry_logger.go +++ b/alogs/entry_logger.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/alogs/go.mod b/alogs/go.mod new file mode 100644 index 0000000..ab23067 --- /dev/null +++ b/alogs/go.mod @@ -0,0 +1,3 @@ +module apacks + +go 1.22 diff --git a/hecate/level.go b/alogs/level.go similarity index 99% rename from hecate/level.go rename to alogs/level.go index e2b870d..b5da485 100644 --- a/hecate/level.go +++ b/alogs/level.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs import ( "math/bits" diff --git a/hecate/loggable.go b/alogs/loggable.go similarity index 98% rename from hecate/loggable.go rename to alogs/loggable.go index 1f3fd6e..5fd661f 100644 --- a/hecate/loggable.go +++ b/alogs/loggable.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/hecate/logger.go b/alogs/logger.go similarity index 98% rename from hecate/logger.go rename to alogs/logger.go index e111d82..3c31f66 100644 --- a/hecate/logger.go +++ b/alogs/logger.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs type ( diff --git a/hecate/logger_core.go b/alogs/logger_core.go similarity index 80% rename from hecate/logger_core.go rename to alogs/logger_core.go index 78b758b..22ef0c0 100644 --- a/hecate/logger_core.go +++ b/alogs/logger_core.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs import ( "errs" @@ -31,31 +31,34 @@ import ( type ( - LoggerCore struct { + LoggerCore struct { sync.RWMutex - EntryFilters - EntryExtenders - EntryAppender - name string - level Level - state State - count int + filters EntryFilters + extenders EntryExtenders + appender EntryAppender - errors errs.ErrorList + name string + level Level + state State + count int + + errors errs.ErrorList //eventos - onStartFn LoggerCoreEventFnc - onStopFn LoggerCoreEventFnc - onFlushFn LoggerCoreEventFnc + onStartFn LoggerCoreEventFnc + onStopFn LoggerCoreEventFnc + onFlushFn LoggerCoreEventFnc - onFatalFn LoggerCoreEntryFnc + onFatalFn LoggerCoreEntryFnc - onErrorFn LoggerCoreErrorFnc + onErrorFn LoggerCoreErrorFnc } - LoggerCoreFnc func(l *LoggerCore) + LoggerCoreFnc func(l *LoggerCore) + + LoggerCoreEventFnc func (l *LoggerCore) error LoggerCoreEntryFnc func (l *LoggerCore, entry *Entry) @@ -67,20 +70,20 @@ type ( func NewLoggerCore (name string, level Level, options ...LoggerCoreFnc) *LoggerCore { l := &LoggerCore { - EntryFilters : *NewEntryFilters(), - EntryAppender: AppendEntryFnc(nopEntryAppender), - name : name, - level : level, - state : StateCreated, - onStartFn : nopOnEvent, - onStopFn : nopOnEvent, + filters : *NewEntryFilters(), + appender : AppendEntryFnc(nopEntryAppender), + name : name, + level : level, + state : StateCreated, + onStartFn: nopOnEvent, + onStopFn : nopOnEvent, } for _,o := range options { o(l) } // if l.onFlushFn == nil { - if fl,is := l.EntryAppender.(iosys.Flusher); is { + if fl,is := l.appender.(iosys.Flusher); is { l.onFlushFn = func(c *LoggerCore) error { return fl.Flush() } } else { @@ -187,8 +190,8 @@ func (l *LoggerCore) log(level Level, msg string, err error, options ...EntryFnc return } - en := l.ExtendEntry(AcquireEntry(l,level,msg,err,options...)) - if er := l.AppendEntry(en); er != nil { + en := l.extenders.ExtendEntry(AcquireEntry(l,level,msg,err,options...)) + if er := l.appender.AppendEntry(en); er != nil { l.handleError(er,en) } l.Unlock() @@ -201,32 +204,22 @@ func (l *LoggerCore) log(level Level, msg string, err error, options ...EntryFnc } -func (l *LoggerCore) Append (entry *Entry) error { +func (l *LoggerCore) Log(entry *Entry) error { l.Lock() if l.state != StateStarted { l.Unlock() return G.ErrLoggerNotStarted } - if !l.level.Has(entry.Level) || entry.Excludes.Has(l.name) || !l.Filter(entry) { + if !l.level.Has(entry.Level) || entry.Excludes.Has(l.name) || !l.filters.Filter(entry) { l.Unlock() return nil } - er := l.AppendEntry(entry) + er := l.appender.AppendEntry(entry) l.Unlock() return er } -func (l *LoggerCore) append (entry *Entry) error { - er := l.AppendEntry(entry) - if er != nil { - l.handleError(er,entry) - return er - } - l.count++ - return nil -} - func (l *LoggerCore) Flush () error { l.Lock() @@ -251,8 +244,6 @@ func (l *LoggerCore) handleError (err error, entry *Entry) { return } l.errors = l.errors.Append(err) - - if l.onErrorFn != nil { l.onErrorFn(l, entry, err) } @@ -286,17 +277,17 @@ func LoggerCoreWithOnError (onError LoggerCoreErrorFnc) LoggerCoreFnc { func LoggerCoreWithExtender (extender ...EntryExtender) LoggerCoreFnc { return func(a *LoggerCore) { - a.EntryExtenders = append(a.EntryExtenders,extender...) } } + a.extenders = append(a.extenders,extender...) } } func LoggerCoreWithFilters (configFilters EntryFiltersFnc) LoggerCoreFnc { return func(a *LoggerCore) { - configFilters(&a.EntryFilters) } } + configFilters(&a.filters) } } func LoggerCoreWithAppender(appender EntryAppender) LoggerCoreFnc { return func(a *LoggerCore) { - a.EntryAppender = appender } } + a.appender = appender } } diff --git a/hecate/logger_manager.go b/alogs/logger_manager.go similarity index 89% rename from hecate/logger_manager.go rename to alogs/logger_manager.go index ab38fd7..0ee7efc 100644 --- a/hecate/logger_manager.go +++ b/alogs/logger_manager.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs import ( "errs" @@ -35,8 +35,9 @@ type ( LoggerManager struct { sync.RWMutex - EntryFilters - EntryExtenders + + filters EntryFilters + extenders EntryExtenders queue queue.GQueue[*Entry] @@ -65,11 +66,11 @@ type ( func NewLoggerManager(name string, level Level, options ...LoggerManagerFnc) *LoggerManager { l := &LoggerManager{ - EntryFilters: *NewEntryFilters(), - level : level, - state : StateCreated, - logErrors : true, - queue : *queue.NewGQueue[*Entry](false), + filters : *NewEntryFilters(), + level : level, + state : StateCreated, + logErrors: true, + queue : *queue.NewGQueue[*Entry](false), } for _,o := range options { o(l) @@ -267,17 +268,17 @@ func (l *LoggerManager) Log (entry *Entry) error { l.Unlock() return G.ErrLoggerNotStarted } - if !l.level.Has(entry.Level) || !l.Filter(entry) { + if !l.level.Has(entry.Level) || !l.filters.Filter(entry) { l.Unlock() return nil } if entry.Logger == nil { //viene de un scope entry.Logger = l - l.ExtendEntry(entry) + l.extenders.ExtendEntry(entry) } - return l.doCores(entry,func(c *LoggerCore, e *Entry) error { return c.Append(e) },G.FmtMsgLogLogErr,false) + return l.doCores(entry,func(c *LoggerCore, e *Entry) error { return c.Log(e) },G.FmtMsgLogLogErr,false) } @@ -290,7 +291,7 @@ func (l *LoggerManager) log (level Level, msg string, err error,options []EntryF l.count++ en := AcquireEntry(l,level,msg,err,options...) - _ = l.doCores(en,func(c *LoggerCore, e *Entry) error { return c.Append(e) },G.FmtMsgLogLogErr,true) + _ = l.doCores(en,func(c *LoggerCore, e *Entry) error { return c.Log(e) },G.FmtMsgLogLogErr,true) if level == LevelFatal && l.onFatalFn != nil { l.onFatalFn(l,en) @@ -306,7 +307,10 @@ func (l *LoggerManager) handleError (err error, entry *Entry) { l.Lock() l.errors = l.errors.Append(err) if l.logErrors { - //todo construir entry desde err + if entry == nil { + entry = AcquireEntry(l,LevelError,err.Error(),err) + } + l.queue.Push(entry) } l.Unlock() @@ -318,7 +322,7 @@ func (l *LoggerManager) handleError (err error, entry *Entry) { func (l *LoggerManager) enqueue() { for en := l.queue.Pop(); en != nil; { - _ = l.doCores(en,func(c *LoggerCore, e *Entry) error { return c.Append(e) },G.FmtMsgLogLogErr,true) + _ = l.doCores(en,func(c *LoggerCore, e *Entry) error { return c.Log(e) },G.FmtMsgLogLogErr,true) ReleaseEntry(en) } } @@ -326,28 +330,28 @@ func (l *LoggerManager) enqueue() { func (l *LoggerManager) doCores (entry *Entry, doFn func(c *LoggerCore, e *Entry) error, msg string, unlock bool) error { var el errs.ErrorList + for _,co := range l.cores { if er := doFn(co,entry); er != nil { - el = el.Append(er) + var en *Entry + ms := fmt.Sprintf(msg,co.name) + ne := errs.NewErrMessage(er,msg) if l.logErrors { - l.queue.Push(AcquireEntry(l,LevelError,fmt.Sprintf(msg,co.name),er, - EntryWithExtender(l.EntryExtenders), + en = AcquireEntry(l,LevelError,ms,ne, + EntryWithExtender(l.extenders), EntryWithExclude (co.name), - EntryWithField (entryFieldCoreName,co.name,true))) + EntryWithField (entryFieldCoreName,co.name,true)) } + l.handleError(er,en) } } if unlock { l.Unlock() } - - if er := errs.NewErrMultiIf(el); er != nil { - l.handleError (er,entry ) - return er - } - return nil + return errs.NewErrMultiIf(el) } + func (l *LoggerManager) findCore(name string) int { for i :=0; i < len(l.cores); i++ { if l.cores[i].name == name { @@ -360,7 +364,7 @@ func (l *LoggerManager) findCore(name string) int { func LoggerManagerWithFilters (configFilters EntryFiltersFnc) LoggerManagerFnc { return func(a *LoggerManager) { - configFilters(&a.EntryFilters) } } + configFilters(&a.filters) } } func LoggerManagerWithOnFatal (onFatal LoggerManagerEntryFnc) LoggerManagerFnc { @@ -375,6 +379,6 @@ func LoggerManagerWithOnError (onError LoggerManagerErrorFnc) LoggerManagerFnc { func LoggerManagerWithExtender (extender ...EntryExtender) LoggerManagerFnc { return func(a *LoggerManager) { - a.EntryExtenders = append(a.EntryExtenders,extender...) } } + a.extenders = append(a.extenders,extender...) } } diff --git a/hecate/logger_scope.go b/alogs/logger_scope.go similarity index 98% rename from hecate/logger_scope.go rename to alogs/logger_scope.go index 2d69e66..fcdf9cb 100644 --- a/hecate/logger_scope.go +++ b/alogs/logger_scope.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs import ( "fmt" diff --git a/hecate/logger_scopes.go b/alogs/logger_scopes.go similarity index 99% rename from hecate/logger_scopes.go rename to alogs/logger_scopes.go index 3fc7b5e..beb2952 100644 --- a/hecate/logger_scopes.go +++ b/alogs/logger_scopes.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs diff --git a/hecate/scope_mode.go b/alogs/scope_mode.go similarity index 98% rename from hecate/scope_mode.go rename to alogs/scope_mode.go index 8bc206e..abb8447 100644 --- a/hecate/scope_mode.go +++ b/alogs/scope_mode.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs const ( diff --git a/hecate/state.go b/alogs/state.go similarity index 98% rename from hecate/state.go rename to alogs/state.go index 3efdc96..8f5ff97 100644 --- a/hecate/state.go +++ b/alogs/state.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package hecate +package alogs const ( diff --git a/proteus/active.go b/apacks/active.go similarity index 99% rename from proteus/active.go rename to apacks/active.go index 223cc53..25b0d35 100644 --- a/proteus/active.go +++ b/apacks/active.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import ( "errs" diff --git a/proteus/flags.go b/apacks/flags.go similarity index 99% rename from proteus/flags.go rename to apacks/flags.go index f06318d..3573995 100644 --- a/proteus/flags.go +++ b/apacks/flags.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import ( "bits" diff --git a/proteus/fold.go b/apacks/fold.go similarity index 99% rename from proteus/fold.go rename to apacks/fold.go index f609067..7f09338 100644 --- a/proteus/fold.go +++ b/apacks/fold.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import ( "bins/chars" diff --git a/apacks/go.mod b/apacks/go.mod new file mode 100644 index 0000000..d03e015 --- /dev/null +++ b/apacks/go.mod @@ -0,0 +1,7 @@ +module apacks + + +go 1.22 + + + diff --git a/proteus/list_pack_builder.go b/apacks/list_pack_builder.go similarity index 99% rename from proteus/list_pack_builder.go rename to apacks/list_pack_builder.go index eaac17e..ce00674 100644 --- a/proteus/list_pack_builder.go +++ b/apacks/list_pack_builder.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import "time" diff --git a/proteus/map_pack_builder.go b/apacks/map_pack_builder.go similarity index 99% rename from proteus/map_pack_builder.go rename to apacks/map_pack_builder.go index 32372d6..94165e5 100644 --- a/proteus/map_pack_builder.go +++ b/apacks/map_pack_builder.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import "time" diff --git a/proteus/object_pack_builder.go b/apacks/object_pack_builder.go similarity index 99% rename from proteus/object_pack_builder.go rename to apacks/object_pack_builder.go index 50dadbc..b125879 100644 --- a/proteus/object_pack_builder.go +++ b/apacks/object_pack_builder.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import "time" diff --git a/proteus/pack_builder.go b/apacks/pack_builder.go similarity index 98% rename from proteus/pack_builder.go rename to apacks/pack_builder.go index 3ea4bfd..c53eb0a 100644 --- a/proteus/pack_builder.go +++ b/apacks/pack_builder.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks diff --git a/proteus/packer.go b/apacks/packer.go similarity index 98% rename from proteus/packer.go rename to apacks/packer.go index d4fb3e4..e6386aa 100644 --- a/proteus/packer.go +++ b/apacks/packer.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks type ( diff --git a/proteus/pjson/active.go b/apacks/pjson/active.go similarity index 93% rename from proteus/pjson/active.go rename to apacks/pjson/active.go index 6042271..23e1bc7 100644 --- a/proteus/pjson/active.go +++ b/apacks/pjson/active.go @@ -26,7 +26,6 @@ package pjson import ( "encoding" "encoding/json" - "proteus" "reflect" "results" "sync" @@ -39,7 +38,7 @@ const ( maxCyclesAfter = 100 - defaultFlags = proteus.Flags(0) + defaultFlags = apacks.Flags(0) ) @@ -59,7 +58,7 @@ var ( jsonMarshalerType: reflect.TypeOf((*json.Marshaler)(nil)).Elem(), textMarshalerType: reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem(), - packMarshalerType: reflect.TypeOf((*proteus.Packer)(nil)).Elem(), + packMarshalerType: reflect.TypeOf((*apacks.Packer)(nil)).Elem(), } ) diff --git a/proteus/pjson/json_packer.go b/apacks/pjson/json_packer.go similarity index 61% rename from proteus/pjson/json_packer.go rename to apacks/pjson/json_packer.go index c6166ff..9f25dbc 100644 --- a/proteus/pjson/json_packer.go +++ b/apacks/pjson/json_packer.go @@ -28,7 +28,7 @@ import ( "crypts" "encoding/json" "errs" - "proteus" + "apacks" "reflect" "time" ) @@ -38,7 +38,7 @@ type ( JSONPacker struct { - state *proteus.State + state *apacks.State dirty bool } @@ -49,7 +49,7 @@ type ( func NewJSONPacker(options ...JSONPackerFnc) *JSONPacker { pk := &JSONPacker{ - state : proteus.NewState(), + state : apacks.NewState(), } for _,o := range options { o(pk) @@ -59,12 +59,12 @@ func NewJSONPacker(options ...JSONPackerFnc) *JSONPacker { -func (p *JSONPacker) Pack (value any, flags proteus.Flags) { +func (p *JSONPacker) Pack (value any, flags apacks.Flags) { if p.state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(p.state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(p.state.Error)) } if p.dirty { - panic(proteus.G.ErrInvalidState) + panic(apacks.G.ErrInvalidState) } p.dirty = true p.PackAny(value,flags) @@ -86,14 +86,14 @@ func (p *JSONPacker) Reset () { func (p *JSONPacker) Release () { p.dirty = false - proteus.ReleaseState(p.state) + apacks.ReleaseState(p.state) } -func (p *JSONPacker) PackAny (value any, flags proteus.Flags) { +func (p *JSONPacker) PackAny (value any, flags apacks.Flags) { if p.state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(p.state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(p.state.Error)) } if value == nil { p.state.W(cjson.G.NullValue) @@ -101,7 +101,7 @@ func (p *JSONPacker) PackAny (value any, flags proteus.Flags) { } switch v := value.(type) { - case proteus.PackBuilder: + case apacks.PackBuilder: p.state.SetError(v.BuildPack(p)) case json.Marshaler: @@ -166,45 +166,45 @@ func (p *JSONPacker) PackAny (value any, flags proteus.Flags) { -func (p *JSONPacker) PackRaw (value []byte, flags proteus.Flags) { packRaw(p.state,value,flags) } +func (p *JSONPacker) PackRaw (value []byte, flags apacks.Flags) { packRaw(p.state,value,flags) } -func (p *JSONPacker) PackBinary (value []byte, flags proteus.Flags) { packBinary(p.state,value,flags) } -func (p *JSONPacker) PackString (value string, flags proteus.Flags) { packString (p.state,value,flags) } +func (p *JSONPacker) PackBinary (value []byte, flags apacks.Flags) { packBinary(p.state,value,flags) } +func (p *JSONPacker) PackString (value string, flags apacks.Flags) { packString (p.state,value,flags) } -func (p *JSONPacker) PackBool (value bool, flags proteus.Flags) { packBool(p.state,value,flags) } +func (p *JSONPacker) PackBool (value bool, flags apacks.Flags) { packBool(p.state,value,flags) } -func (p *JSONPacker) PackInt8 (value int8 , flags proteus.Flags) { packInt(p.state,int64(value),flags) } -func (p *JSONPacker) PackInt16 (value int16, flags proteus.Flags) { packInt(p.state,int64(value),flags) } -func (p *JSONPacker) PackInt32 (value int32, flags proteus.Flags) { packInt(p.state,int64(value),flags) } -func (p *JSONPacker) PackInt64 (value int64, flags proteus.Flags) { packInt(p.state,value,flags)} +func (p *JSONPacker) PackInt8 (value int8 , flags apacks.Flags) { packInt(p.state,int64(value),flags) } +func (p *JSONPacker) PackInt16 (value int16, flags apacks.Flags) { packInt(p.state,int64(value),flags) } +func (p *JSONPacker) PackInt32 (value int32, flags apacks.Flags) { packInt(p.state,int64(value),flags) } +func (p *JSONPacker) PackInt64 (value int64, flags apacks.Flags) { packInt(p.state,value,flags)} -func (p *JSONPacker) PackUInt8 (value uint8 , flags proteus.Flags) { packUInt(p.state,uint64(value),flags) } -func (p *JSONPacker) PackUInt16 (value uint16, flags proteus.Flags) { packUInt(p.state,uint64(value),flags) } -func (p *JSONPacker) PackUInt32 (value uint32, flags proteus.Flags) { packUInt(p.state,uint64(value),flags) } -func (p *JSONPacker) PackUInt64 (value uint64, flags proteus.Flags) { packUInt(p.state, value,flags) } +func (p *JSONPacker) PackUInt8 (value uint8 , flags apacks.Flags) { packUInt(p.state,uint64(value),flags) } +func (p *JSONPacker) PackUInt16 (value uint16, flags apacks.Flags) { packUInt(p.state,uint64(value),flags) } +func (p *JSONPacker) PackUInt32 (value uint32, flags apacks.Flags) { packUInt(p.state,uint64(value),flags) } +func (p *JSONPacker) PackUInt64 (value uint64, flags apacks.Flags) { packUInt(p.state, value,flags) } -func (p *JSONPacker) PackFloat32 (value float32, flags proteus.Flags) { packFloatString(p.state, float64(value), flags, 32) } -func (p *JSONPacker) PackFloat64 (value float64, flags proteus.Flags) { packFloatString(p.state, value, flags, 64) } +func (p *JSONPacker) PackFloat32 (value float32, flags apacks.Flags) { packFloatString(p.state, float64(value), flags, 32) } +func (p *JSONPacker) PackFloat64 (value float64, flags apacks.Flags) { packFloatString(p.state, value, flags, 64) } -func (p *JSONPacker) PackDate (value time.Time, flags proteus.Flags) { packDate(p.state,value,flags) } +func (p *JSONPacker) PackDate (value time.Time, flags apacks.Flags) { packDate(p.state,value,flags) } -func (p *JSONPacker) PackList (builder func(proteus.ListPackBuilder, proteus.Flags), flags proteus.Flags) { - p.packCompound('[',']',builder==nil,func(pk *JSONPacker, fl proteus.Flags){ builder(pk,fl) },flags) +func (p *JSONPacker) PackList (builder func(apacks.ListPackBuilder, apacks.Flags), flags apacks.Flags) { + p.packCompound('[',']',builder==nil,func(pk *JSONPacker, fl apacks.Flags){ builder(pk,fl) },flags) } -func (p *JSONPacker) PackMap (builder func(proteus.MapPackBuilder, proteus.Flags), flags proteus.Flags) { - p.packCompound('{','}',builder==nil,func(pk *JSONPacker, fl proteus.Flags){ builder(pk,fl) },flags) +func (p *JSONPacker) PackMap (builder func(apacks.MapPackBuilder, apacks.Flags), flags apacks.Flags) { + p.packCompound('{','}',builder==nil,func(pk *JSONPacker, fl apacks.Flags){ builder(pk,fl) },flags) } -func (p *JSONPacker) PackObject(builder func(proteus.ObjectPackBuilder, proteus.Flags), flags proteus.Flags) { - p.packCompound('{','}',builder==nil,func(pk *JSONPacker, fl proteus.Flags){ builder(pk,fl) },flags) +func (p *JSONPacker) PackObject(builder func(apacks.ObjectPackBuilder, apacks.Flags), flags apacks.Flags) { + p.packCompound('{','}',builder==nil,func(pk *JSONPacker, fl apacks.Flags){ builder(pk,fl) },flags) } -func (p *JSONPacker) packCompound (opener, closer byte, isnil bool, buildFn func(*JSONPacker, proteus.Flags), flags proteus.Flags) { +func (p *JSONPacker) packCompound (opener, closer byte, isnil bool, buildFn func(*JSONPacker, apacks.Flags), flags apacks.Flags) { if p.state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(p.state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(p.state.Error)) } if isnil { p.state.W(cjson.G.NullValue) @@ -229,9 +229,9 @@ func (p *JSONPacker) packCompound (opener, closer byte, isnil bool, buildFn func -func packRaw (state *proteus.State, value []byte, flags proteus.Flags) { +func packRaw (state *apacks.State, value []byte, flags apacks.Flags) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } if value == nil { state.W(cjson.G.NullValue) @@ -244,9 +244,9 @@ func packRaw (state *proteus.State, value []byte, flags proteus.Flags) { state.WOQ(flags.Quote(),'"',value) } -func packString (state *proteus.State, value string , flags proteus.Flags) { +func packString (state *apacks.State, value string , flags apacks.Flags) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } if len(value) == 0 { @@ -255,7 +255,7 @@ func packString (state *proteus.State, value string , flags proteus.Flags) { } if flags.Encrypted() { - packEncrypted(state, []byte(value), flags|proteus.FlagBinary64) + packEncrypted(state, []byte(value), flags|apacks.FlagBinary64) return } @@ -268,7 +268,7 @@ func packString (state *proteus.State, value string , flags proteus.Flags) { } -func packEncrypted (state *proteus.State, value []byte, flags proteus.Flags) { +func packEncrypted (state *apacks.State, value []byte, flags apacks.Flags) { r := state.Encrypter.Encrypt(value) if !r.Ok() { state.SetError(r.Fail()) @@ -276,16 +276,16 @@ func packEncrypted (state *proteus.State, value []byte, flags proteus.Flags) { } if !flags.Binary() { - flags|= proteus.FlagBinary64 + flags|= apacks.FlagBinary64 } packBinary(state,value,flags) } -func packBinary (state *proteus.State, value []byte , flags proteus.Flags) { +func packBinary (state *apacks.State, value []byte , flags apacks.Flags) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } if flags.Bin64() { @@ -296,48 +296,48 @@ func packBinary (state *proteus.State, value []byte , flags proteus.Flags) { state.SetError(cjson.WriteBase32(state.ABuffer,value)) return } - state.SetError(proteus.G.ErrUnsupportedType) + state.SetError(apacks.G.ErrUnsupportedType) } -func packBool (state *proteus.State, value bool , flags proteus.Flags) { +func packBool (state *apacks.State, value bool , flags apacks.Flags) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } cjson.WriteBool(state.ABuffer,value,flags.Quote()) } -func packInt (state *proteus.State, value int64 , flags proteus.Flags) { +func packInt (state *apacks.State, value int64 , flags apacks.Flags) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } cjson.WriteInt(state.ABuffer,value,flags.Quote()) } -func packUInt (state *proteus.State, value uint64 , flags proteus.Flags) { +func packUInt (state *apacks.State, value uint64 , flags apacks.Flags) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } cjson.WriteUint(state.ABuffer,value,flags.Quote()) } -func packFloat (state *proteus.State, value float64, flags proteus.Flags) { +func packFloat (state *apacks.State, value float64, flags apacks.Flags) { packFloatString(state, value, flags, 64) } -func packFloatString (state *proteus.State, f float64, flags proteus.Flags, bits int) { +func packFloatString (state *apacks.State, f float64, flags apacks.Flags, bits int) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } cjson.WriteFloat(state.ABuffer,f,bits,flags.Quote()) } -func packDate(state *proteus.State, value time.Time, flags proteus.Flags) { +func packDate(state *apacks.State, value time.Time, flags apacks.Flags) { if state.Error != nil { - panic(proteus.G.ErrInvalidState.WrapWithCause(state.Error)) + panic(apacks.G.ErrInvalidState.WrapWithCause(state.Error)) } cjson.WriteDate(state.ABuffer,value,flags.DateFormat(),true) } @@ -347,7 +347,7 @@ func packDate(state *proteus.State, value time.Time, flags proteus.Flags) { -func packListString (state *proteus.State, list []string, flags proteus.Flags) { +func packListString (state *apacks.State, list []string, flags apacks.Flags) { if !checkList(state,list == nil, len(list) ==0) { return } @@ -365,7 +365,7 @@ func packListString (state *proteus.State, list []string, flags proteus.Flags) { } -func packListBool (state *proteus.State, list []bool, flags proteus.Flags) { +func packListBool (state *apacks.State, list []bool, flags apacks.Flags) { if !checkList(state,list == nil, len(list) ==0) { return } @@ -383,7 +383,7 @@ func packListBool (state *proteus.State, list []bool, flags proteus.Flags) { } -func packListInt [T int | int8 | int16 | int32 | int64](state *proteus.State, list []T, flags proteus.Flags) { +func packListInt [T int | int8 | int16 | int32 | int64](state *apacks.State, list []T, flags apacks.Flags) { if !checkList(state,list == nil, len(list) ==0) { return } @@ -401,7 +401,7 @@ func packListInt [T int | int8 | int16 | int32 | int64](state *proteus.State, l } -func packListUInt [T uint | uint8 | uint16 | uint32 | uint64](state *proteus.State, list []T, flags proteus.Flags) { +func packListUInt [T uint | uint8 | uint16 | uint32 | uint64](state *apacks.State, list []T, flags apacks.Flags) { if !checkList(state,list == nil, len(list) ==0) { return } @@ -419,7 +419,7 @@ func packListUInt [T uint | uint8 | uint16 | uint32 | uint64](state *proteus.Sta } -func packListFloat[T float32 | float64](state *proteus.State, list []T, flags proteus.Flags, bits int) { +func packListFloat[T float32 | float64](state *apacks.State, list []T, flags apacks.Flags, bits int) { if !checkList(state,list == nil, len(list) ==0) { return } @@ -436,7 +436,7 @@ func packListFloat[T float32 | float64](state *proteus.State, list []T, flags pr state.WriteByte(']') } -func packListDate (state *proteus.State, list []time.Time, flags proteus.Flags) { +func packListDate (state *apacks.State, list []time.Time, flags apacks.Flags) { if !checkList(state,list == nil, len(list) ==0) { return } @@ -454,7 +454,7 @@ func packListDate (state *proteus.State, list []time.Time, flags proteus.Flags) } -func checkList (state *proteus.State, isNull, isEmpty bool) bool { +func checkList (state *apacks.State, isNull, isEmpty bool) bool { if isNull { state.Write2Byte('"','"') return false diff --git a/apacks/pjson/list_pack_builder.go b/apacks/pjson/list_pack_builder.go new file mode 100644 index 0000000..128dfb2 --- /dev/null +++ b/apacks/pjson/list_pack_builder.go @@ -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 ( + "apacks" + "time" +) + +func (p *JSONPacker) ItemAny (value any, flags apacks.Flags) { p.addItem(func(){ p.PackAny(value,flags) }) } + + +func (p *JSONPacker) ItemRaw (value []byte, flags apacks.Flags) { p.addItem(func() { p.PackRaw(value,flags) }) } + +func (p *JSONPacker) ItemBinary (value []byte, flags apacks.Flags) { p.addItem(func (){ p.PackBinary(value,flags) }) } + +func (p *JSONPacker) ItemString (value string, flags apacks.Flags) { p.addItem(func (){ p.PackString(value,flags) }) } + + +func (p *JSONPacker) ItemBool (value bool, flags apacks.Flags) { p.addItem(func (){ p.PackBool(value,flags) }) } + +func (p *JSONPacker) ItemInt8 (value int8 , flags apacks.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) } +func (p *JSONPacker) ItemInt16 (value int16, flags apacks.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) } +func (p *JSONPacker) ItemInt32 (value int32, flags apacks.Flags) { p.addItem(func (){ packInt(p.state,int64(value),flags) }) } +func (p *JSONPacker) ItemInt64 (value int64, flags apacks.Flags) { p.addItem(func (){ packInt(p.state,value,flags) }) } + +func (p *JSONPacker) ItemUInt8 (value uint8 , flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } +func (p *JSONPacker) ItemUInt16 (value uint16, flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } +func (p *JSONPacker) ItemUInt32 (value uint32, flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } +func (p *JSONPacker) ItemUInt64 (value uint64, flags apacks.Flags){ p.addItem(func (){ packUInt(p.state,uint64(value),flags) }) } + +func (p *JSONPacker) ItemFloat32 (value float32, flags apacks.Flags){ p.addItem(func (){ packFloatString(p.state,float64(value),flags,32)})} +func (p *JSONPacker) ItemFloat64 (value float64, flags apacks.Flags){ p.addItem(func (){ packFloatString(p.state,value,flags,64) })} + +func (p *JSONPacker) ItemDate (value time.Time, flags apacks.Flags) { p.addItem(func(){ packDate(p.state,value,flags); p.state.Inc() })} + + +func (p *JSONPacker) ItemList (builder func(apacks.ListPackBuilder, apacks.Flags), flags apacks.Flags) { + p.addItem(func(){ p.PackList(builder,flags) }) } + +func (p *JSONPacker) ItemMap (builder func(apacks.MapPackBuilder, apacks.Flags), flags apacks.Flags) { + p.addItem(func(){ p.PackMap(builder,flags) }) } + +func (p *JSONPacker) ItemObject(builder func(apacks.ObjectPackBuilder, apacks.Flags), flags apacks.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() + } +} + + diff --git a/proteus/pjson/map_pack_builder.go b/apacks/pjson/map_pack_builder.go similarity index 66% rename from proteus/pjson/map_pack_builder.go rename to apacks/pjson/map_pack_builder.go index 0761a9e..2b7eb12 100644 --- a/proteus/pjson/map_pack_builder.go +++ b/apacks/pjson/map_pack_builder.go @@ -24,56 +24,56 @@ package pjson import ( - "proteus" + "apacks" "reflect" "time" ) -func (p *JSONPacker) KeyValueAny (key any, value any, flags proteus.Flags) { +func (p *JSONPacker) KeyValueAny (key any, value any, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackAny(value,flags)}) } -func (p *JSONPacker) KeyValueRaw (key any,value []byte, flags proteus.Flags) { +func (p *JSONPacker) KeyValueRaw (key any,value []byte, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackRaw(value,flags)}) } -func (p *JSONPacker) KeyValueBinary (key any, value []byte, flags proteus.Flags) { +func (p *JSONPacker) KeyValueBinary (key any, value []byte, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackBinary(value,flags)}) } -func (p *JSONPacker) KeyValueString (key any, value string, flags proteus.Flags) { +func (p *JSONPacker) KeyValueString (key any, value string, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackString(value,flags)}) } -func (p *JSONPacker) KeyValueBool (key any, value bool, flags proteus.Flags) { +func (p *JSONPacker) KeyValueBool (key any, value bool, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackBool(value,flags)}) } -func (p *JSONPacker) KeyValueInt8 (key any, value int8 , flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackInt64(int64(value),flags)}) } -func (p *JSONPacker) KeyValueInt16 (key any, value int16, flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackInt64(int64(value),flags)}) } -func (p *JSONPacker) KeyValueInt32 (key any, value int32, flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackInt64(int64(value),flags)}) } -func (p *JSONPacker) KeyValueInt64 (key any, value int64, flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackInt64(value,flags)}) } +func (p *JSONPacker) KeyValueInt8 (key any, value int8 , flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackInt64(int64(value),flags)}) } +func (p *JSONPacker) KeyValueInt16 (key any, value int16, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackInt64(int64(value),flags)}) } +func (p *JSONPacker) KeyValueInt32 (key any, value int32, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackInt64(int64(value),flags)}) } +func (p *JSONPacker) KeyValueInt64 (key any, value int64, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackInt64(value,flags)}) } -func (p *JSONPacker) KeyValueUInt8 (key any, value uint8 , flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(uint64(value),flags)}) } -func (p *JSONPacker) KeyValueUInt16 (key any, value uint16, flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(uint64(value),flags)}) } -func (p *JSONPacker) KeyValueUInt32 (key any, value uint32, flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(uint64(value),flags)}) } -func (p *JSONPacker) KeyValueUInt64 (key any, value uint64, flags proteus.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(value,flags)}) } +func (p *JSONPacker) KeyValueUInt8 (key any, value uint8 , flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(uint64(value),flags)}) } +func (p *JSONPacker) KeyValueUInt16 (key any, value uint16, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(uint64(value),flags)}) } +func (p *JSONPacker) KeyValueUInt32 (key any, value uint32, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(uint64(value),flags)}) } +func (p *JSONPacker) KeyValueUInt64 (key any, value uint64, flags apacks.Flags) { p.addKeyValue(key, func(){ p.PackUInt64(value,flags)}) } -func (p *JSONPacker) KeyValueFloat32(key any, value float32, flags proteus.Flags){ +func (p *JSONPacker) KeyValueFloat32(key any, value float32, flags apacks.Flags){ p.addKeyValue(key,func(){ p.PackFloat32(value, flags) }) } -func (p *JSONPacker) KeyValueFloat64(key any, value float64, flags proteus.Flags){ +func (p *JSONPacker) KeyValueFloat64(key any, value float64, flags apacks.Flags){ p.addKeyValue(key,func(){ p.PackFloat64(value, flags) }) } -func (p *JSONPacker) KeyValueDate (key any, value time.Time, flags proteus.Flags){ +func (p *JSONPacker) KeyValueDate (key any, value time.Time, flags apacks.Flags){ p.addKeyValue(key,func(){ p.PackDate(value, flags) }) } -func (p *JSONPacker) KeyValueList (key any, builder func(proteus.ListPackBuilder, proteus.Flags), flags proteus.Flags) { +func (p *JSONPacker) KeyValueList (key any, builder func(apacks.ListPackBuilder, apacks.Flags), flags apacks.Flags) { p.addKeyValue(key,func(){ p.PackList(builder, flags) }) } -func (p *JSONPacker) KeyValueMap (key any, builder func(proteus.MapPackBuilder, proteus.Flags), flags proteus.Flags) { +func (p *JSONPacker) KeyValueMap (key any, builder func(apacks.MapPackBuilder, apacks.Flags), flags apacks.Flags) { p.addKeyValue(key,func(){ p.PackMap(builder, flags) }) } -func (p *JSONPacker) KeyValueObject (key any, builder func(proteus.ObjectPackBuilder, proteus.Flags), flags proteus.Flags) { +func (p *JSONPacker) KeyValueObject (key any, builder func(apacks.ObjectPackBuilder, apacks.Flags), flags apacks.Flags) { p.addKeyValue(key,func(){ p.PackObject(builder, flags) }) } @@ -94,16 +94,16 @@ func (p *JSONPacker) addKeyValue(key any, caller func()) { func (p *JSONPacker) packStringifyKey(key any) { switch v := key.(type) { - case string : p.PackString(v, proteus.FlagScapeHTML) - case float32: p.PackFloat32(v, proteus.FlagScapeHTML|proteus.FlagQuote) - case float64: p.PackFloat64(v, proteus.FlagScapeHTML|proteus.FlagQuote) + case string : p.PackString(v, apacks.FlagScapeHTML) + case float32: p.PackFloat32(v, apacks.FlagScapeHTML|apacks.FlagQuote) + case float64: p.PackFloat64(v, apacks.FlagScapeHTML|apacks.FlagQuote) default: me := &rMapEntry{ v : reflect.ValueOf(key), } fn := stringifyRKey(me.v.Type()) if fn == nil { - p.state.SetError(proteus.G.ErrInvalidKey) + p.state.SetError(apacks.G.ErrInvalidKey) return } if er := fn(me,me.v); er != nil { diff --git a/proteus/pjson/object_pack_builder.go b/apacks/pjson/object_pack_builder.go similarity index 81% rename from proteus/pjson/object_pack_builder.go rename to apacks/pjson/object_pack_builder.go index 10688df..9c7243d 100644 --- a/proteus/pjson/object_pack_builder.go +++ b/apacks/pjson/object_pack_builder.go @@ -24,75 +24,75 @@ package pjson import ( - "proteus" + "apacks" "time" ) -func (p *JSONPacker) FieldAny (name string, value any, flags proteus.Flags) { +func (p *JSONPacker) FieldAny (name string, value any, flags apacks.Flags) { p.addField(name, func() { p.PackAny(value, flags) }) } -func (p *JSONPacker) FieldRaw (name string, value []byte, flags proteus.Flags){ +func (p *JSONPacker) FieldRaw (name string, value []byte, flags apacks.Flags){ p.addField(name, func() { p.PackRaw(value, flags) }) } -func (p *JSONPacker) FieldBinary (name string, value []byte, flags proteus.Flags) { +func (p *JSONPacker) FieldBinary (name string, value []byte, flags apacks.Flags) { p.addField(name, func() { p.PackBinary(value, flags) }) } -func (p *JSONPacker) FieldString (name string, value string, flags proteus.Flags) { +func (p *JSONPacker) FieldString (name string, value string, flags apacks.Flags) { p.addField(name, func() { p.PackString(value, flags) }) } -func (p *JSONPacker) FieldBool (name string, value bool, flags proteus.Flags) { +func (p *JSONPacker) FieldBool (name string, value bool, flags apacks.Flags) { p.addField(name, func() { p.PackBool(value, flags) }) } -func (p *JSONPacker) FieldInt8 (name string, value int8 , flags proteus.Flags) { +func (p *JSONPacker) FieldInt8 (name string, value int8 , flags apacks.Flags) { p.addField(name, func() { p.PackInt64(int64(value), flags) })} -func (p *JSONPacker) FieldInt16 (name string, value int16, flags proteus.Flags) { +func (p *JSONPacker) FieldInt16 (name string, value int16, flags apacks.Flags) { p.addField(name, func() { p.PackInt64(int64(value), flags) })} -func (p *JSONPacker) FieldInt32 (name string, value int32, flags proteus.Flags) { +func (p *JSONPacker) FieldInt32 (name string, value int32, flags apacks.Flags) { p.addField(name, func() { p.PackInt64(int64(value), flags) }) } -func (p *JSONPacker) FieldInt64 (name string, value int64, flags proteus.Flags) { +func (p *JSONPacker) FieldInt64 (name string, value int64, flags apacks.Flags) { p.addField(name, func() { p.PackInt64(value, flags) }) } -func (p *JSONPacker) FieldUInt8 (name string, value uint8, flags proteus.Flags) { +func (p *JSONPacker) FieldUInt8 (name string, value uint8, flags apacks.Flags) { p.addField(name, func() { p.PackUInt64(uint64(value), flags) }) } -func (p *JSONPacker) FieldUInt16 (name string, value uint16, flags proteus.Flags) { +func (p *JSONPacker) FieldUInt16 (name string, value uint16, flags apacks.Flags) { p.addField(name,func(){ p.PackUInt64(uint64(value), flags) }) } -func (p *JSONPacker) FieldUInt32 (name string, value uint32, flags proteus.Flags) { +func (p *JSONPacker) FieldUInt32 (name string, value uint32, flags apacks.Flags) { p.addField(name,func(){ p.PackUInt64(uint64(value), flags) }) } -func (p *JSONPacker) FieldUInt64 (name string, value uint64, flags proteus.Flags) { +func (p *JSONPacker) FieldUInt64 (name string, value uint64, flags apacks.Flags) { p.addField(name,func(){ p.PackUInt64(value, flags) }) } -func (p *JSONPacker) FieldFloat32(name string, value float32,flags proteus.Flags) { +func (p *JSONPacker) FieldFloat32(name string, value float32,flags apacks.Flags) { p.addField(name,func(){ p.PackFloat32(value, flags) }) } -func (p *JSONPacker) FieldFloat64(name string, value float64,flags proteus.Flags) { +func (p *JSONPacker) FieldFloat64(name string, value float64,flags apacks.Flags) { p.addField(name,func(){ p.PackFloat64(value, flags) }) } -func (p *JSONPacker) FieldDate (name string, value time.Time,flags proteus.Flags) { +func (p *JSONPacker) FieldDate (name string, value time.Time,flags apacks.Flags) { p.addField(name,func(){ p.PackDate(value, flags) }) } -func (p *JSONPacker) FieldList (name string, builder func(proteus.ListPackBuilder, proteus.Flags), flags proteus.Flags) { +func (p *JSONPacker) FieldList (name string, builder func(apacks.ListPackBuilder, apacks.Flags), flags apacks.Flags) { p.addField(name,func(){ p.PackList(builder, flags) }) } -func (p *JSONPacker) FieldMap (name string, builder func(proteus.MapPackBuilder, proteus.Flags), flags proteus.Flags) { +func (p *JSONPacker) FieldMap (name string, builder func(apacks.MapPackBuilder, apacks.Flags), flags apacks.Flags) { p.addField(name,func(){ p.PackMap(builder, flags) }) } -func (p *JSONPacker) FieldObject (name string, builder func(proteus.ObjectPackBuilder, proteus.Flags), flags proteus.Flags) { +func (p *JSONPacker) FieldObject (name string, builder func(apacks.ObjectPackBuilder, apacks.Flags), flags apacks.Flags) { p.addField(name,func(){ p.PackObject(builder, flags) }) } @@ -102,7 +102,7 @@ func (p *JSONPacker) addField(name string, caller func()) { if p.state.Count() > 0 { p.state.WriteByte(',') } - packString(p.state,name, proteus.FlagScapeHTML) + packString(p.state,name, apacks.FlagScapeHTML) if p.state.Error != nil { return } diff --git a/proteus/pjson/rpacker.go b/apacks/pjson/rpacker.go similarity index 66% rename from proteus/pjson/rpacker.go rename to apacks/pjson/rpacker.go index 1958ce0..1a6e435 100644 --- a/proteus/pjson/rpacker.go +++ b/apacks/pjson/rpacker.go @@ -24,7 +24,7 @@ package pjson import ( - "proteus" + apacks "packs" "reflect" "sync" ) @@ -33,7 +33,7 @@ type ( - rPackerFnc func (state *proteus.State, rvalue reflect.Value, flags proteus.Flags) + rPackerFnc func (state *apacks.State, rvalue reflect.Value, flags apacks.Flags) ) @@ -49,7 +49,7 @@ func rTypePacker (rtype reflect.Type) rPackerFnc { wg.Add(1) - fi,ld := g.packersCache.LoadOrStore(rtype, rPackerFnc(func (e *proteus.State, v reflect.Value, f proteus.Flags) { + fi,ld := g.packersCache.LoadOrStore(rtype, rPackerFnc(func (e *apacks.State, v reflect.Value, f apacks.Flags) { wg.Wait() fn(e,v,f) })) @@ -68,20 +68,20 @@ func rTypePacker (rtype reflect.Type) rPackerFnc { func _rTypePacker(rtype reflect.Type) rPackerFnc { switch rtype.Kind() { - case reflect.Bool : return func(s *proteus.State, v reflect.Value, f proteus.Flags) { packBool (s,v.Bool (),f )} - case reflect.String : return func(s *proteus.State, v reflect.Value, f proteus.Flags) { packString(s,v.String(),f )} + case reflect.Bool : return func(s *apacks.State, v reflect.Value, f apacks.Flags) { packBool (s,v.Bool (),f )} + case reflect.String : return func(s *apacks.State, v reflect.Value, f apacks.Flags) { packString(s,v.String(),f )} case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, - reflect.Int64 : return func(s *proteus.State, v reflect.Value, f proteus.Flags) { packInt (s,v.Int (),f )} + reflect.Int64 : return func(s *apacks.State, v reflect.Value, f apacks.Flags) { packInt (s,v.Int (),f )} case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, - reflect.Uint64 : return func(s *proteus.State, v reflect.Value, f proteus.Flags) { packUInt (s,v.Uint (),f )} - case reflect.Float32: return func(s *proteus.State, v reflect.Value, f proteus.Flags) { packFloatString(s,v.Float(),f,32) } - case reflect.Float64: return func(s *proteus.State, v reflect.Value, f proteus.Flags) { packFloatString(s,v.Float(),f,64) } + reflect.Uint64 : return func(s *apacks.State, v reflect.Value, f apacks.Flags) { packUInt (s,v.Uint (),f )} + case reflect.Float32: return func(s *apacks.State, v reflect.Value, f apacks.Flags) { packFloatString(s,v.Float(),f,32) } + case reflect.Float64: return func(s *apacks.State, v reflect.Value, f apacks.Flags) { packFloatString(s,v.Float(),f,64) } case reflect.Pointer: return rPointerPacker(rtype) @@ -106,8 +106,8 @@ func _rTypePacker(rtype reflect.Type) rPackerFnc { } -func unsupportedTypePacker(state *proteus.State, _ reflect.Value, _ proteus.Flags) { - state.SetError(proteus.G.ErrUnsupportedType) +func unsupportedTypePacker(state *apacks.State, _ reflect.Value, _ apacks.Flags) { + state.SetError(apacks.G.ErrUnsupportedType) } diff --git a/proteus/pjson/rpacker_interface.go b/apacks/pjson/rpacker_interface.go similarity index 92% rename from proteus/pjson/rpacker_interface.go rename to apacks/pjson/rpacker_interface.go index 03139cb..492e00a 100644 --- a/proteus/pjson/rpacker_interface.go +++ b/apacks/pjson/rpacker_interface.go @@ -25,11 +25,11 @@ package pjson import ( "codecs/cjson" - "proteus" + "apacks" "reflect" ) -func rInterfacePacker (s *proteus.State, v reflect.Value, f proteus.Flags) { +func rInterfacePacker (s *apacks.State, v reflect.Value, f apacks.Flags) { if v.IsNil() { s.W(cjson.G.NullValue) return diff --git a/proteus/pjson/rpacker_key.go b/apacks/pjson/rpacker_key.go similarity index 95% rename from proteus/pjson/rpacker_key.go rename to apacks/pjson/rpacker_key.go index aa42372..7df9628 100644 --- a/proteus/pjson/rpacker_key.go +++ b/apacks/pjson/rpacker_key.go @@ -26,7 +26,7 @@ package pjson import ( "encoding" "math" - "proteus" + "apacks" "reflect" "strconv" ) @@ -45,7 +45,7 @@ func _stringifyRKey(rt reflect.Type) rMapEntryFnc { if rt.Kind() == reflect.String { return func(e *rMapEntry, k reflect.Value) error { e.k = k.String() - e.f = proteus.FlagScapeHTML + e.f = apacks.FlagScapeHTML return nil } } @@ -58,7 +58,7 @@ func _stringifyRKey(rt reflect.Type) rMapEntryFnc { bf, er := (k.Interface().(encoding.TextMarshaler)).MarshalText() if er == nil { e.k = string(bf) - e.f = proteus.FlagScapeHTML + e.f = apacks.FlagScapeHTML } return er } @@ -92,7 +92,7 @@ func _stringifyRKey(rt reflect.Type) rMapEntryFnc { if k.Type().Kind() == reflect.String { e.k = k.String() - e.f = proteus.FlagScapeHTML + e.f = apacks.FlagScapeHTML return nil } @@ -103,7 +103,7 @@ func _stringifyRKey(rt reflect.Type) rMapEntryFnc { bf, er := t.MarshalText() if er == nil { e.k = string(bf) - e.f = proteus.FlagScapeHTML + e.f = apacks.FlagScapeHTML } return er } @@ -128,7 +128,7 @@ func _stringifyRKey(rt reflect.Type) rMapEntryFnc { return nil default: - return proteus.G.ErrInvalidKey + return apacks.G.ErrInvalidKey } } diff --git a/proteus/pjson/rpacker_list.go b/apacks/pjson/rpacker_list.go similarity index 85% rename from proteus/pjson/rpacker_list.go rename to apacks/pjson/rpacker_list.go index aee7341..a60b688 100644 --- a/proteus/pjson/rpacker_list.go +++ b/apacks/pjson/rpacker_list.go @@ -25,7 +25,7 @@ package pjson import ( "codecs/cjson" - "proteus" + "apacks" "reflect" ) @@ -58,7 +58,7 @@ func newRList(rtype reflect.Type) *rList { -func (p rList) packBinary (s *proteus.State, v reflect.Value, f proteus.Flags) { +func (p rList) packBinary (s *apacks.State, v reflect.Value, f apacks.Flags) { if f.Binary() { packBinary(s, v.Interface().([]byte), f) return @@ -67,7 +67,7 @@ func (p rList) packBinary (s *proteus.State, v reflect.Value, f proteus.Flags) { } -func (p rList) packBinarySlice (s *proteus.State, v reflect.Value, f proteus.Flags) { +func (p rList) packBinarySlice (s *apacks.State, v reflect.Value, f apacks.Flags) { if f.Binary() { packBinary(s, v.Interface().([]byte), f) return @@ -78,7 +78,7 @@ func (p rList) packBinarySlice (s *proteus.State, v reflect.Value, f proteus.Fla -func (p rList) packSlice(s *proteus.State, v reflect.Value, f proteus.Flags) { +func (p rList) packSlice(s *apacks.State, v reflect.Value, f apacks.Flags) { if v.IsNil() { s.W(cjson.G.NullValue) return @@ -95,7 +95,7 @@ func (p rList) packSlice(s *proteus.State, v reflect.Value, f proteus.Flags) { if fn,ok := s.CheckCycle(cp); ok { defer fn() } else { - s.SetError(proteus.G.ErrRedundantPack) + s.SetError(apacks.G.ErrRedundantPack) return } } @@ -105,7 +105,7 @@ func (p rList) packSlice(s *proteus.State, v reflect.Value, f proteus.Flags) { -func (p rList) pack (s *proteus.State, v reflect.Value, f proteus.Flags) { +func (p rList) pack (s *apacks.State, v reflect.Value, f apacks.Flags) { if v.IsNil() { s.W(cjson.G.NullValue) return diff --git a/proteus/pjson/rpacker_map.go b/apacks/pjson/rpacker_map.go similarity index 92% rename from proteus/pjson/rpacker_map.go rename to apacks/pjson/rpacker_map.go index d783f2e..aaf7f7a 100644 --- a/proteus/pjson/rpacker_map.go +++ b/apacks/pjson/rpacker_map.go @@ -25,7 +25,7 @@ package pjson import ( "codecs/cjson" - "proteus" + "apacks" "reflect" "sort" ) @@ -53,9 +53,9 @@ func newRMap(rtype reflect.Type) *rMap { } -func (p *rMap) pack (s *proteus.State, v reflect.Value, f proteus.Flags) { +func (p *rMap) pack (s *apacks.State, v reflect.Value, f apacks.Flags) { if p.keyFn == nil { - s.SetError(proteus.G.ErrInvalidKey) + s.SetError(apacks.G.ErrInvalidKey) return } @@ -72,7 +72,7 @@ func (p *rMap) pack (s *proteus.State, v reflect.Value, f proteus.Flags) { if fn,ok := s.CheckCycle(v.UnsafePointer()); ok { defer fn() } else { - s.SetError(proteus.G.ErrRedundantPack) + s.SetError(apacks.G.ErrRedundantPack) return } } diff --git a/proteus/pjson/rpacker_map_entry.go b/apacks/pjson/rpacker_map_entry.go similarity index 97% rename from proteus/pjson/rpacker_map_entry.go rename to apacks/pjson/rpacker_map_entry.go index ecef24c..1345b88 100644 --- a/proteus/pjson/rpacker_map_entry.go +++ b/apacks/pjson/rpacker_map_entry.go @@ -24,7 +24,7 @@ package pjson import ( - "proteus" + "apacks" "reflect" ) @@ -32,7 +32,7 @@ type ( rMapEntry struct { - f proteus.Flags // flags + f apacks.Flags // flags v reflect.Value // value k string // Key } diff --git a/proteus/pjson/rpacker_object.go b/apacks/pjson/rpacker_object.go similarity index 91% rename from proteus/pjson/rpacker_object.go rename to apacks/pjson/rpacker_object.go index 9682862..8219fc0 100644 --- a/proteus/pjson/rpacker_object.go +++ b/apacks/pjson/rpacker_object.go @@ -25,7 +25,7 @@ package pjson import ( "mems" - "proteus" + "apacks" "reflect" "sort" ) @@ -46,7 +46,7 @@ func rObjectPacker (rtype reflect.Type) rPackerFnc { if !ok { op,_ = g.fieldsCache.LoadOrStore(rtype,*newRObject(rtype)) } - return func(s *proteus.State, value reflect.Value, flags proteus.Flags) { + return func(s *apacks.State, value reflect.Value, flags apacks.Flags) { op.(rObject).pack(s,value,flags) } //return (op.(rObject)).pack @@ -87,7 +87,7 @@ func newRObject(rtype reflect.Type) *rObject { continue } - nm, fg, has := proteus.FlagsFromPackTag(sf.Tag) + nm, fg, has := apacks.FlagsFromPackTag(sf.Tag) if !has { nm, fg, has = jsonTags(sf.Tag) } @@ -95,7 +95,7 @@ func newRObject(rtype reflect.Type) *rObject { if nm == "-" || fg.Omit() { continue } - if !proteus.CheckTag(nm) { + if !apacks.CheckTag(nm) { nm = "" } } @@ -116,7 +116,7 @@ func newRObject(rtype reflect.Type) *rObject { reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.Float32, reflect.Float64, reflect.String: - fg = fg| proteus.FlagQuote + fg = fg| apacks.FlagQuote } } @@ -133,7 +133,7 @@ func newRObject(rtype reflect.Type) *rObject { flags : fg, } of.nameB = []byte(of.name) - of.foldFn= proteus.GetFoldFunc(of.nameB) + of.foldFn= apacks.GetFoldFunc(of.nameB) // BuildPack nameEscHTML and nameNonEsc ahead of time. nms.Reset() @@ -213,7 +213,7 @@ func newRObject(rtype reflect.Type) *rObject { -func (o rObject) pack (s *proteus.State, v reflect.Value, f proteus.Flags) { +func (o rObject) pack (s *apacks.State, v reflect.Value, f apacks.Flags) { nx := byte('{') FieldLoop: for i:= range o.fields { @@ -250,11 +250,11 @@ FieldLoop: } -func jsonTags (tag reflect.StructTag) (string, proteus.Flags,bool) { - return proteus.FlagsFromTag(tag,jsonTag,func(n string) proteus.Flags { +func jsonTags (tag reflect.StructTag) (string, apacks.Flags,bool) { + return apacks.FlagsFromTag(tag,jsonTag,func(n string) apacks.Flags { switch n { - case "omitempty" : return proteus.FlagOmitEmpty - case "quote" : return proteus.FlagQuote + case "omitempty" : return apacks.FlagOmitEmpty + case "quote" : return apacks.FlagQuote default : return 0 } }) diff --git a/proteus/pjson/rpacker_object_field.go b/apacks/pjson/rpacker_object_field.go similarity index 97% rename from proteus/pjson/rpacker_object_field.go rename to apacks/pjson/rpacker_object_field.go index b881cdd..bd97241 100644 --- a/proteus/pjson/rpacker_object_field.go +++ b/apacks/pjson/rpacker_object_field.go @@ -24,7 +24,7 @@ package pjson import ( - "proteus" + "apacks" "reflect" ) @@ -39,9 +39,9 @@ type ( isTagged bool index []int rtype reflect.Type - flags proteus.Flags + flags apacks.Flags - foldFn proteus.FoldFnc + foldFn apacks.FoldFnc packerFn rPackerFnc } diff --git a/proteus/pjson/rpacker_pointer.go b/apacks/pjson/rpacker_pointer.go similarity index 94% rename from proteus/pjson/rpacker_pointer.go rename to apacks/pjson/rpacker_pointer.go index 46987aa..030212c 100644 --- a/proteus/pjson/rpacker_pointer.go +++ b/apacks/pjson/rpacker_pointer.go @@ -25,7 +25,7 @@ package pjson import ( "codecs/cjson" - "proteus" + "apacks" "reflect" ) @@ -47,7 +47,7 @@ func newRPointer (rtype reflect.Type) *rPointer { } -func (p rPointer) pack (s *proteus.State, v reflect.Value, f proteus.Flags) { +func (p rPointer) pack (s *apacks.State, v reflect.Value, f apacks.Flags) { if v.IsNil() { s.W(cjson.G.NullValue) return diff --git a/proteus/pjson/rpacker_value.go b/apacks/pjson/rpacker_value.go similarity index 89% rename from proteus/pjson/rpacker_value.go rename to apacks/pjson/rpacker_value.go index d1a14f1..c0a7a71 100644 --- a/proteus/pjson/rpacker_value.go +++ b/apacks/pjson/rpacker_value.go @@ -24,7 +24,7 @@ package pjson import ( - "proteus" + "apacks" "reflect" ) @@ -36,6 +36,6 @@ func rValuePacker (rvalue reflect.Value) rPackerFnc { } -func invalidValuePacker(state *proteus.State, _ reflect.Value, _ proteus.Flags) { - state.SetError(proteus.G.ErrInvalidValue) +func invalidValuePacker(state *apacks.State, _ reflect.Value, _ apacks.Flags) { + state.SetError(apacks.G.ErrInvalidValue) } \ No newline at end of file diff --git a/proteus/state.go b/apacks/state.go similarity index 99% rename from proteus/state.go rename to apacks/state.go index b8c4bca..f85f485 100644 --- a/proteus/state.go +++ b/apacks/state.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import ( "crypts" diff --git a/proteus/value_packer.go b/apacks/value_packer.go similarity index 99% rename from proteus/value_packer.go rename to apacks/value_packer.go index d0badf2..84ba82c 100644 --- a/proteus/value_packer.go +++ b/apacks/value_packer.go @@ -21,7 +21,7 @@ // limitations under the License. // ------------------------------------------------------------------------ -package proteus +package apacks import "time" diff --git a/app/main.go b/app/main.go index 85a7da0..fe13e5c 100644 --- a/app/main.go +++ b/app/main.go @@ -1,10 +1,9 @@ package main import ( + "alogs/ejson" "errs" "fmt" - "hecate" - "hecate/ejson" "os" ) @@ -16,7 +15,7 @@ func Print (err error) { } -func Append (entry *hecate.Entry) error { +func Append (entry *alogs.Entry) error { rs := ejson.EncodeEntry(entry) if !rs.Ok() { @@ -30,9 +29,9 @@ func Append (entry *hecate.Entry) error { func main() { - l := hecate.NewLoggerManager("Main",hecate.LevelAll) + l := alogs.NewLoggerManager("Main",alogs.LevelAll) - l.AddCore(hecate.NewLoggerCore("MiLogger",hecate.LevelAll,hecate.LoggerCoreWithAppender(hecate.AppendEntryFnc(Append)))) + l.AddCore(alogs.NewLoggerCore("MiLogger",alogs.LevelAll,alogs.LoggerCoreWithAppender(alogs.AppendEntryFnc(Append)))) l.Start(true) l.Warn("Esto es un mensage") diff --git a/core/errs/err_message.go b/core/errs/err_message.go new file mode 100644 index 0000000..7b14c0d --- /dev/null +++ b/core/errs/err_message.go @@ -0,0 +1,63 @@ +// ------------------------------------------------------------------------ +// Project active2 +// Active Thing (activething.com) git.activething.com/go +// +// File name err_message.go +// Created by DEV +// Modified 27/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 errs + + + +type ( + + ErrMessage struct { + error + message string + } +) + + +func NewErrMessage (err error, message string) *ErrMessage { + if err == nil{ + return nil + } + return &ErrMessage{ + error: err, + message: message } } + + + +func (e ErrMessage) Message () string { + return e.message } + + + +func (e ErrMessage) WrapWithInfo (options ...ErrInfoFnc) error { + return WrapWithInfo(e,options...) } + + +func (e ErrMessage) WrapWithCause(cause error) error { + return WrapWithCause(e,cause) } + + +func (e ErrMessage) WrapWithTrace(offset int) error { + return WrapWithTrace(e,offset) } + + diff --git a/go.work b/go.work index ccd5ca0..54793d8 100644 --- a/go.work +++ b/go.work @@ -18,8 +18,8 @@ use ( ./core/ctxs ./core/atypes ./core/mems - ./proteus - ./hecate + ./apacks + ./alogs ./app ) \ No newline at end of file diff --git a/hecate/go.mod b/hecate/go.mod deleted file mode 100644 index 36a8ebe..0000000 --- a/hecate/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module hecate - -go 1.22 diff --git a/proteus/go.mod b/proteus/go.mod deleted file mode 100644 index 535ac7e..0000000 --- a/proteus/go.mod +++ /dev/null @@ -1,7 +0,0 @@ -module proteus - - -go 1.22 - - - diff --git a/proteus/pjson/list_pack_builder.go b/proteus/pjson/list_pack_builder.go deleted file mode 100644 index afbeb8b..0000000 --- a/proteus/pjson/list_pack_builder.go +++ /dev/null @@ -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 ( - "proteus" - "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() - } -} - -