Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1edc2712ed
|
|||
|
63c28b4141
|
|||
|
b01e659bb4
|
+29
-3
@@ -2,12 +2,13 @@ package dataext
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
|
||||||
"git.blackforestbytes.com/BlackForestBytes/goext/syncext"
|
|
||||||
"github.com/rs/xid"
|
|
||||||
"iter"
|
"iter"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.blackforestbytes.com/BlackForestBytes/goext/langext"
|
||||||
|
"git.blackforestbytes.com/BlackForestBytes/goext/syncext"
|
||||||
|
"github.com/rs/xid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PubSub is a simple Pub/Sub Broker
|
// PubSub is a simple Pub/Sub Broker
|
||||||
@@ -162,6 +163,31 @@ func (ps *PubSub[TNamespace, TData]) PublishWithTimeout(ns TNamespace, data TDat
|
|||||||
return subscriber, actualReceiver
|
return subscriber, actualReceiver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PublishAsync sends `data` to all subscriber
|
||||||
|
// does not wait for subscriber (this method returns immediately), waits at most {timeout} seconds on channels (async)
|
||||||
|
func (ps *PubSub[TNamespace, TData]) PublishAsync(ns TNamespace, data TData, timeout time.Duration) (subscriber int) {
|
||||||
|
ps.masterLock.Lock()
|
||||||
|
subs := langext.ArrCopy(ps.subscriptions[ns])
|
||||||
|
ps.masterLock.Unlock()
|
||||||
|
|
||||||
|
subscriber = len(subs)
|
||||||
|
|
||||||
|
for _, sub := range subs {
|
||||||
|
func() {
|
||||||
|
sub.subLock.Lock()
|
||||||
|
defer sub.subLock.Unlock()
|
||||||
|
|
||||||
|
if sub.Func != nil {
|
||||||
|
go func() { sub.Func(data) }()
|
||||||
|
} else if sub.Chan != nil {
|
||||||
|
go func() { _ = syncext.WriteChannelWithTimeout(sub.Chan, data, timeout) }()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
return subscriber
|
||||||
|
}
|
||||||
|
|
||||||
func (ps *PubSub[TNamespace, TData]) SubscribeByCallback(ns TNamespace, fn func(TData)) PubSubSubscription {
|
func (ps *PubSub[TNamespace, TData]) SubscribeByCallback(ns TNamespace, fn func(TData)) PubSubSubscription {
|
||||||
ps.masterLock.Lock()
|
ps.masterLock.Lock()
|
||||||
defer ps.masterLock.Unlock()
|
defer ps.masterLock.Unlock()
|
||||||
|
|||||||
+8
-2
@@ -1,4 +1,4 @@
|
|||||||
package excelbuilder
|
package excelext
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
@@ -78,7 +78,7 @@ func (em *ExcelMapper[T]) InitNewFile(sheetName string) (*excelize.File, error)
|
|||||||
|
|
||||||
func (em *ExcelMapper[T]) InitStyles(f *excelize.File) error {
|
func (em *ExcelMapper[T]) InitStyles(f *excelize.File) error {
|
||||||
styleDate, err := f.NewStyle(&excelize.Style{
|
styleDate, err := f.NewStyle(&excelize.Style{
|
||||||
CustomNumFmt: new("dd.mm.yyyy"),
|
CustomNumFmt: langext.Ptr("dd.mm.yyyy"),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -286,6 +286,12 @@ func (em *ExcelMapper[T]) BuildSingleSheet(f *excelize.File, sheetName string, d
|
|||||||
iRow++
|
iRow++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//for i, col := range em.colDefinitions {
|
||||||
|
// if col.width == nil {
|
||||||
|
// //TODO https://github.com/qax-os/excelize/pull/1386
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package excelext
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"git.blackforestbytes.com/BlackForestBytes/goext/rfctime"
|
||||||
|
"github.com/360EntSecGroup-Skylar/excelize"
|
||||||
|
)
|
||||||
|
|
||||||
|
func c(row int, col int) string {
|
||||||
|
return excelize.ToAlphaString(col) + strconv.Itoa(row)
|
||||||
|
}
|
||||||
|
|
||||||
|
func excelizeOptTime(t *rfctime.RFC3339NanoTime) any {
|
||||||
|
if t == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return t.Time()
|
||||||
|
}
|
||||||
|
|
||||||
|
func excelizeOptDate(t *rfctime.Date) any {
|
||||||
|
if t == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return t.TimeUTC()
|
||||||
|
}
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
package goext
|
package goext
|
||||||
|
|
||||||
const GoextVersion = "0.0.629"
|
const GoextVersion = "0.0.632"
|
||||||
|
|
||||||
const GoextVersionTimestamp = "2026-03-14T14:09:13+0100"
|
const GoextVersionTimestamp = "2026-04-13T16:07:00+0100"
|
||||||
|
|||||||
Reference in New Issue
Block a user