mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-20 22:26:30 +00:00
update dependencies (#296)
This commit is contained in:
parent
2aaec82732
commit
829a934d23
124 changed files with 2453 additions and 1588 deletions
25
go.mod
25
go.mod
|
@ -3,7 +3,7 @@ module github.com/superseriousbusiness/gotosocial
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
git.iim.gay/grufwub/go-store v0.4.2
|
||||
codeberg.org/gruf/go-store v1.0.3
|
||||
github.com/ReneKroon/ttlcache v1.7.0
|
||||
github.com/buckket/go-blurhash v1.1.0
|
||||
github.com/coreos/go-oidc/v3 v3.0.0
|
||||
|
@ -18,7 +18,7 @@ require (
|
|||
github.com/h2non/filetype v1.1.1
|
||||
github.com/jackc/pgconn v1.10.0
|
||||
github.com/jackc/pgx/v4 v4.13.0
|
||||
github.com/microcosm-cc/bluemonday v1.0.15
|
||||
github.com/microcosm-cc/bluemonday v1.0.16
|
||||
github.com/mitchellh/mapstructure v1.4.1
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||
github.com/oklog/ulid v1.3.1
|
||||
|
@ -28,9 +28,9 @@ require (
|
|||
github.com/superseriousbusiness/exifremove v0.0.0-20210330092427-6acd27eac203
|
||||
github.com/superseriousbusiness/oauth2/v4 v4.3.2-SSB
|
||||
github.com/tdewolff/minify/v2 v2.9.21
|
||||
github.com/uptrace/bun v1.0.14
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.0.14
|
||||
github.com/uptrace/bun/dialect/sqlitedialect v1.0.14
|
||||
github.com/uptrace/bun v1.0.17
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.0.17
|
||||
github.com/uptrace/bun/dialect/sqlitedialect v1.0.17
|
||||
github.com/urfave/cli/v2 v2.3.0
|
||||
github.com/wagslane/go-password-validator v0.3.0
|
||||
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
|
||||
|
@ -42,13 +42,14 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
git.iim.gay/grufwub/fastpath v0.2.2 // indirect
|
||||
git.iim.gay/grufwub/go-bufpool v0.2.1 // indirect
|
||||
git.iim.gay/grufwub/go-bytes v0.7.0 // indirect
|
||||
git.iim.gay/grufwub/go-errors v0.2.3 // indirect
|
||||
git.iim.gay/grufwub/go-hashenc v0.3.0 // indirect
|
||||
git.iim.gay/grufwub/go-mutexes v0.5.1 // indirect
|
||||
git.iim.gay/grufwub/go-nowish v0.3.5 // indirect
|
||||
codeberg.org/gruf/go-bytes v1.0.2 // indirect
|
||||
codeberg.org/gruf/go-errors v1.0.0 // indirect
|
||||
codeberg.org/gruf/go-fastpath v1.0.2 // indirect
|
||||
codeberg.org/gruf/go-hashenc v1.0.1 // indirect
|
||||
codeberg.org/gruf/go-logger v1.0.3 // indirect
|
||||
codeberg.org/gruf/go-mutexes v1.0.0 // indirect
|
||||
codeberg.org/gruf/go-nowish v1.0.2 // indirect
|
||||
codeberg.org/gruf/go-pools v1.0.2 // indirect
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
|
|
75
go.sum
75
go.sum
|
@ -30,24 +30,30 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
|
|||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||
codeberg.org/gruf/go-bytes v1.0.0/go.mod h1:1v/ibfaosfXSZtRdW2rWaVrDXMc9E3bsi/M9Ekx39cg=
|
||||
codeberg.org/gruf/go-bytes v1.0.1/go.mod h1:1v/ibfaosfXSZtRdW2rWaVrDXMc9E3bsi/M9Ekx39cg=
|
||||
codeberg.org/gruf/go-bytes v1.0.2 h1:malqE42Ni+h1nnYWBUAJaDDtEzF4aeN4uPN8DfMNNvo=
|
||||
codeberg.org/gruf/go-bytes v1.0.2/go.mod h1:1v/ibfaosfXSZtRdW2rWaVrDXMc9E3bsi/M9Ekx39cg=
|
||||
codeberg.org/gruf/go-cache v1.0.0/go.mod h1:nfefEzEvCd+uFetFioBQMmzcT/NNxdxc6e49qxDbFgg=
|
||||
codeberg.org/gruf/go-errors v1.0.0 h1:jzEnAwICwGLTP4pHaGD9aD3HVR0ZzJb4AB01xTPKpF4=
|
||||
codeberg.org/gruf/go-errors v1.0.0/go.mod h1:G66SPILZJMOGRRHwAK7KSEk9N5fEnCk7asFc+De1SP0=
|
||||
codeberg.org/gruf/go-fastpath v1.0.1/go.mod h1:edveE/Kp3Eqi0JJm0lXYdkVrB28cNUkcb/bRGFTPqeI=
|
||||
codeberg.org/gruf/go-fastpath v1.0.2 h1:O3nuYPMXnN89dsgAwVFU5iCGINtPJdITWmbRe2an/iQ=
|
||||
codeberg.org/gruf/go-fastpath v1.0.2/go.mod h1:edveE/Kp3Eqi0JJm0lXYdkVrB28cNUkcb/bRGFTPqeI=
|
||||
codeberg.org/gruf/go-hashenc v1.0.1 h1:EBvNe2wW8IPMUqT1XihB6/IM6KMJDLMFBxIUvmsy1f8=
|
||||
codeberg.org/gruf/go-hashenc v1.0.1/go.mod h1:IfHhPCVScOiYmJLqdCQT9bYVS1nxNTV4ewMUvFWDPtc=
|
||||
codeberg.org/gruf/go-logger v1.0.3 h1:ccCpkG+2RMV/TgkaivQoWoodSlKqAfixonFY7qR70M8=
|
||||
codeberg.org/gruf/go-logger v1.0.3/go.mod h1:BLwlr04s5qjniVZ8okCT9fepGL+B/dfmyZ9zBjnjDWs=
|
||||
codeberg.org/gruf/go-mutexes v1.0.0 h1:s15kUdv/ufCFH+kmMOAOTUUJ/TK9uaJU+rNSwRI9jY8=
|
||||
codeberg.org/gruf/go-mutexes v1.0.0/go.mod h1:y2hbGLkWVHhNyxBOIVsA3/y2QMm6RSrYsC3sLVZ4EXM=
|
||||
codeberg.org/gruf/go-nowish v1.0.0/go.mod h1:70nvICNcqQ9OHpF07N614Dyk7cpL5ToWU1K1ZVCec2s=
|
||||
codeberg.org/gruf/go-nowish v1.0.2 h1:/y8g38x44sD8JeqBPCkzqLoe0pReR1CTF8p6jXCOG1s=
|
||||
codeberg.org/gruf/go-nowish v1.0.2/go.mod h1:70nvICNcqQ9OHpF07N614Dyk7cpL5ToWU1K1ZVCec2s=
|
||||
codeberg.org/gruf/go-pools v1.0.2 h1:B0X6yoCL9FVmnvyoizb1SYRwMYPWwEJBjPnBMM5ILos=
|
||||
codeberg.org/gruf/go-pools v1.0.2/go.mod h1:MjUV3H6IASyBeBPCyCr7wjPpSNu8E2N87LG4r4TAyok=
|
||||
codeberg.org/gruf/go-store v1.0.3 h1:lpMlE/T73dJyv4oPmkmq3/Xv92TM4J7mFnV6smhnMzE=
|
||||
codeberg.org/gruf/go-store v1.0.3/go.mod h1:vcBYUK8+WwMqvtK0Ma2kl9lVZooaKkw2GvGnAs0E7kI=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
git.iim.gay/grufwub/fastpath v0.2.2 h1:ST89k6XukDE2xN5zZ0VGi7Jo2A/DPhik9dr3/ny4QGg=
|
||||
git.iim.gay/grufwub/fastpath v0.2.2/go.mod h1:HYwrf4ku2CfP/1D3ItBqBbFHayuWkiV6BOwYQQ86dbo=
|
||||
git.iim.gay/grufwub/go-bufpool v0.2.1 h1:TRwEzLtdvutp3+W/5wQYxmW6lAz9twQKmsfiUO0XfSU=
|
||||
git.iim.gay/grufwub/go-bufpool v0.2.1/go.mod h1:X/QI5K0hxyhWPRtu+D+ZRzLqEOqD1Ns/rpNNWq2R1DU=
|
||||
git.iim.gay/grufwub/go-bytes v0.7.0 h1:tGwIrVOANiaifx7702yDdkp5uMVYGk+rheZd6ZuSvEo=
|
||||
git.iim.gay/grufwub/go-bytes v0.7.0/go.mod h1:ADc2p+R74ZjQf0FzIaIUnLyuHdbGCk7ldlaiHauAs+U=
|
||||
git.iim.gay/grufwub/go-errors v0.2.3 h1:MSvzN/tW5Vj5Rm4EmBfdVpzyYjAY92ANE+ESNpZnjvw=
|
||||
git.iim.gay/grufwub/go-errors v0.2.3/go.mod h1:rfKZpjI7A67zJfzpt5zfwAUMA7gec0EHXZEuYv/A9UI=
|
||||
git.iim.gay/grufwub/go-fixedmap v0.1.3/go.mod h1:KB4nV2+NeBMVFvFwpdgsP74AsMiDeX68oD20wiC2S3I=
|
||||
git.iim.gay/grufwub/go-hashenc v0.3.0 h1:2etpzwoUTPTLvlWZ9u9a+FUCGBcVU37x5zM5XZ0kahQ=
|
||||
git.iim.gay/grufwub/go-hashenc v0.3.0/go.mod h1:wjztiGUzaZsEw5kKE6gz/UOFN2cbcDnGiUSUjOLXi4o=
|
||||
git.iim.gay/grufwub/go-mutexes v0.5.1 h1:HjMUvTCsEWfX8lW7VaYwwkdOA2Bjg8qZjHJAT+cbMBA=
|
||||
git.iim.gay/grufwub/go-mutexes v0.5.1/go.mod h1:oCWMmmM+puqoq8y3b2ZEvmazx9XLbcvUIugtMPJswhE=
|
||||
git.iim.gay/grufwub/go-nowish v0.3.5 h1:RBBSPAIZcsqd0QfscMZ55ogNwM+uERoBKKLlNMgFhxs=
|
||||
git.iim.gay/grufwub/go-nowish v0.3.5/go.mod h1:oII7zlMQMFclFzgmI1qRd7DdQXKNHWcJYnwHFgdgiRI=
|
||||
git.iim.gay/grufwub/go-store v0.4.2 h1:VjcuyFDW64Pu0fvO9Nww33eLBewrQbtjAKT99YQSJsw=
|
||||
git.iim.gay/grufwub/go-store v0.4.2/go.mod h1:qXeDj6+LlMJsZul3RwP2LLBSOK57Rl/vdWtQdGIbL9g=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||
|
@ -58,7 +64,6 @@ github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
|||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4=
|
||||
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
|
||||
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
|
||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff/go.mod h1:+RTT1BOk5P97fT2CiHkbFQwkK3mjsFAP6zCYV2aXtjw=
|
||||
|
@ -172,6 +177,8 @@ github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
|
|||
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b h1:khEcpUM4yFcxg4/FHQWkvVRmgijNXRfzkIDHh23ggEo=
|
||||
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM=
|
||||
github.com/goccy/go-json v0.4.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.5.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.7.8 h1:CvMH7LotYymYuLGEohBM1lTZWX4g6jzWUUl2aLFuBoE=
|
||||
github.com/goccy/go-json v0.7.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||
|
@ -224,8 +231,9 @@ github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
|
@ -333,6 +341,10 @@ github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd
|
|||
github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kpango/fastime v1.0.16 h1:1prFG/3pTjzcDeCTxt98VB4IvjxcySLs0ldCEhZg0R8=
|
||||
github.com/kpango/fastime v1.0.16/go.mod h1:lVqUTcXmQnk1wriyvq5DElbRSRDC0XtqbXQRdz0Eo+g=
|
||||
github.com/kpango/glg v1.5.8 h1:ZyxQa0Ft27dWci+2X7vMCCjHGEZCTFWLBHnLrAzxQZs=
|
||||
github.com/kpango/glg v1.5.8/go.mod h1:HI0g/1T4dmUhdoT2isXHrCM4FeNjc+t7fZujjvqYIeQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
|
@ -363,8 +375,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
|
|||
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
|
||||
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc=
|
||||
github.com/microcosm-cc/bluemonday v1.0.15 h1:J4uN+qPng9rvkBZBoBb8YGR+ijuklIMpSOZZLjYpbeY=
|
||||
github.com/microcosm-cc/bluemonday v1.0.15/go.mod h1:ZLvAzeakRwrGnzQEvstVzVt3ZpqOF2+sdFr0Om+ce30=
|
||||
github.com/microcosm-cc/bluemonday v1.0.16 h1:kHmAq2t7WPWLjiGvzKa5o3HzSfahUKiOq7fAPUiMNIc=
|
||||
github.com/microcosm-cc/bluemonday v1.0.16/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM=
|
||||
github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
|
@ -469,12 +481,12 @@ github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn
|
|||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=
|
||||
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
|
||||
github.com/uptrace/bun v1.0.14 h1:rwWFTdnwX8/6CMTptxVgxly7h/YgfOO4WK7vrWPJRC0=
|
||||
github.com/uptrace/bun v1.0.14/go.mod h1:rs7qARtH6aqLtcfmloWM6qn90iyY53N2ScLQssIrevw=
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.0.14 h1:GnaKZ9k8eek9Y4q4+rt/jklucdai+oQpAW77WhKJEvE=
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.0.14/go.mod h1:hQr4NoUPcb1tMEj7WTQ+fmKdoglR0xoKQKJ5EYuYJK0=
|
||||
github.com/uptrace/bun/dialect/sqlitedialect v1.0.14 h1:2S3dHGMpDT9d023Wm94+QdEDqh69xUtDBEJBhDVjmbo=
|
||||
github.com/uptrace/bun/dialect/sqlitedialect v1.0.14/go.mod h1:c189/WJIZt2ixRLrMYfOS5HUcsxRNfH6mAAnNKQcyrs=
|
||||
github.com/uptrace/bun v1.0.17 h1:ti3IyOieIKaBO2pmxB1Rj8R1WpXw7utaRmr5kL9WrSs=
|
||||
github.com/uptrace/bun v1.0.17/go.mod h1:rs7qARtH6aqLtcfmloWM6qn90iyY53N2ScLQssIrevw=
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.0.17 h1:Cjm2YL1jAD00eclC6uf8MT6iPpHaXAyKL2GbxNYZdaE=
|
||||
github.com/uptrace/bun/dialect/pgdialect v1.0.17/go.mod h1:b7tIxPup1wzryFZfUghMd2wIoYj9XzL+0Vr2OhQvAJA=
|
||||
github.com/uptrace/bun/dialect/sqlitedialect v1.0.17 h1:ca3c/YnkrL1fp/Ok0lDGNbpgF0t07WWGHdh2NAzwctM=
|
||||
github.com/uptrace/bun/dialect/sqlitedialect v1.0.17/go.mod h1:HH9VihgggYYA4igpgw/5qJEsC7UfpJPqfXgp5DvVJfU=
|
||||
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
|
@ -516,15 +528,23 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
|||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/goleak v0.10.0 h1:G3eWbSNIskeRqtsN/1uI5B+eP73y3JUuBsv9AZjehb4=
|
||||
go.uber.org/goleak v0.10.0/go.mod h1:VCZuO8V8mFPlL0F5J5GK1rtHV3DrFcQ1R8ryq7FK0aI=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.7.0 h1:zaiO/rmgFjbmCXdSYJWQcdvOCsthmdaHfr3Gm2Kx4Ec=
|
||||
go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
|
||||
go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U=
|
||||
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
|
||||
golang.org/x/crypto v0.0.0-20180527072434-ab813273cd59/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
|
@ -843,6 +863,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|||
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/account"
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"fmt"
|
||||
"net/http/httptest"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/followrequest"
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package status_test
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/status"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package user_test
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/user"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package user_test
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/user"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/security"
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"crypto/rsa"
|
||||
"time"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/s2s/webfinger"
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/api/client/account"
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/go-fed/activity/streams"
|
||||
"github.com/go-fed/activity/streams/vocab"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/go-fed/activity/pub"
|
||||
"github.com/go-fed/httpsig"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package account_test
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/go-fed/activity/pub"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
|
|
|
@ -21,7 +21,7 @@ package media
|
|||
import (
|
||||
"context"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/sirupsen/logrus"
|
||||
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/go-fed/activity/streams"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package testrig
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/federation"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/transport"
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package testrig
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/media"
|
||||
)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package testrig
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/db"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/email"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/federation"
|
||||
|
|
|
@ -25,9 +25,9 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/kv"
|
||||
"git.iim.gay/grufwub/go-store/storage"
|
||||
"git.iim.gay/grufwub/go-store/util"
|
||||
"codeberg.org/gruf/go-store/kv"
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
)
|
||||
|
||||
// NewTestStorage returns a new in memory storage with the default test config
|
||||
|
|
9
vendor/codeberg.org/gruf/go-bytes/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-bytes/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -7,13 +7,11 @@ import (
|
|||
// Buffer is a very simple buffer implementation that allows
|
||||
// access to and reslicing of the underlying byte slice.
|
||||
type Buffer struct {
|
||||
noCopy noCopy
|
||||
B []byte
|
||||
}
|
||||
|
||||
func NewBuffer(b []byte) Buffer {
|
||||
return Buffer{
|
||||
noCopy: noCopy{},
|
||||
B: b,
|
||||
}
|
||||
}
|
||||
|
@ -131,8 +129,3 @@ func (b *Buffer) Guarantee(size int) {
|
|||
b.B = nb[:b.Len()]
|
||||
}
|
||||
}
|
||||
|
||||
type noCopy struct{}
|
||||
|
||||
func (n *noCopy) Lock() {}
|
||||
func (n *noCopy) Unlock() {}
|
9
vendor/codeberg.org/gruf/go-errors/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-errors/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
vendor/codeberg.org/gruf/go-errors/README.md
generated
vendored
Normal file
1
vendor/codeberg.org/gruf/go-errors/README.md
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
simple but powerful errors library that allows providing context information with errors
|
74
vendor/codeberg.org/gruf/go-errors/data.go
generated
vendored
Normal file
74
vendor/codeberg.org/gruf/go-errors/data.go
generated
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
package errors
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
"codeberg.org/gruf/go-logger"
|
||||
)
|
||||
|
||||
// global logfmt data formatter
|
||||
var logfmt = logger.TextFormat{Strict: false}
|
||||
|
||||
// KV is a structure for setting key-value pairs in ErrorData
|
||||
type KV struct {
|
||||
Key string
|
||||
Value interface{}
|
||||
}
|
||||
|
||||
// ErrorData defines a way to set and access contextual error data.
|
||||
// The default implementation of this is thread-safe
|
||||
type ErrorData interface {
|
||||
// Value will attempt to fetch value for given key in ErrorData
|
||||
Value(string) (interface{}, bool)
|
||||
|
||||
// Append adds the supplied key-values to ErrorData, similar keys DO overwrite
|
||||
Append(...KV)
|
||||
|
||||
// String returns a string representation of the ErrorData
|
||||
String() string
|
||||
}
|
||||
|
||||
// NewData returns a new ErrorData implementation
|
||||
func NewData() ErrorData {
|
||||
return &errorData{
|
||||
data: make(map[string]interface{}, 10),
|
||||
}
|
||||
}
|
||||
|
||||
// errorData is our ErrorData implementation, this is essentially
|
||||
// just a thread-safe string-interface map implementation
|
||||
type errorData struct {
|
||||
data map[string]interface{}
|
||||
buf bytes.Buffer
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (d *errorData) Value(key string) (interface{}, bool) {
|
||||
d.mu.Lock()
|
||||
v, ok := d.data[key]
|
||||
d.mu.Unlock()
|
||||
return v, ok
|
||||
}
|
||||
|
||||
func (d *errorData) Append(kvs ...KV) {
|
||||
d.mu.Lock()
|
||||
for i := range kvs {
|
||||
k := kvs[i].Key
|
||||
v := kvs[i].Value
|
||||
d.data[k] = v
|
||||
}
|
||||
d.mu.Unlock()
|
||||
}
|
||||
|
||||
func (d *errorData) String() string {
|
||||
d.mu.Lock()
|
||||
|
||||
d.buf.Reset()
|
||||
d.buf.B = append(d.buf.B, '{')
|
||||
logfmt.AppendFields(&d.buf, d.data)
|
||||
d.buf.B = append(d.buf.B, '}')
|
||||
|
||||
d.mu.Unlock()
|
||||
return d.buf.StringPtr()
|
||||
}
|
180
vendor/codeberg.org/gruf/go-errors/errors.go
generated
vendored
Normal file
180
vendor/codeberg.org/gruf/go-errors/errors.go
generated
vendored
Normal file
|
@ -0,0 +1,180 @@
|
|||
package errors
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ErrorContext defines a wrappable error with the ability to hold extra contextual information
|
||||
type ErrorContext interface {
|
||||
// implement base error interface
|
||||
error
|
||||
|
||||
// Is identifies whether the receiver contains / is the target
|
||||
Is(error) bool
|
||||
|
||||
// Unwrap reveals the underlying wrapped error (if any!)
|
||||
Unwrap() error
|
||||
|
||||
// Value attempts to fetch contextual data for given key from this ErrorContext
|
||||
Value(string) (interface{}, bool)
|
||||
|
||||
// Append allows adding contextual data to this ErrorContext
|
||||
Append(...KV) ErrorContext
|
||||
|
||||
// Data returns the contextual data structure associated with this ErrorContext
|
||||
Data() ErrorData
|
||||
}
|
||||
|
||||
// New returns a new ErrorContext created from string
|
||||
func New(msg string) ErrorContext {
|
||||
return stringError(msg)
|
||||
}
|
||||
|
||||
// Newf returns a new ErrorContext created from format string
|
||||
func Newf(s string, a ...interface{}) ErrorContext {
|
||||
return stringError(fmt.Sprintf(s, a...))
|
||||
}
|
||||
|
||||
// Wrap ensures supplied error is an ErrorContext, wrapping if necessary
|
||||
func Wrap(err error) ErrorContext {
|
||||
// Nil error, do nothing
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check if this is already wrapped somewhere in stack
|
||||
if xerr, ok := err.(*errorContext); ok {
|
||||
return xerr
|
||||
} else if As(err, &xerr) {
|
||||
// This is really not an ideal situation,
|
||||
// but we try to make do by salvaging the
|
||||
// contextual error data from earlier in
|
||||
// stack, setting current error to the top
|
||||
// and setting the unwrapped error to inner
|
||||
return &errorContext{
|
||||
data: xerr.data,
|
||||
innr: Unwrap(err),
|
||||
err: err,
|
||||
}
|
||||
}
|
||||
|
||||
// Return new Error type
|
||||
return &errorContext{
|
||||
data: NewData(),
|
||||
innr: nil,
|
||||
err: err,
|
||||
}
|
||||
}
|
||||
|
||||
// WrapMsg wraps supplied error as inner, returning an ErrorContext
|
||||
// with a new outer error made from the supplied message string
|
||||
func WrapMsg(err error, msg string) ErrorContext {
|
||||
// Nil error, do nothing
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check if this is already wrapped
|
||||
var xerr *errorContext
|
||||
if As(err, &xerr) {
|
||||
return &errorContext{
|
||||
data: xerr.data,
|
||||
innr: err,
|
||||
err: New(msg),
|
||||
}
|
||||
}
|
||||
|
||||
// Return new wrapped error
|
||||
return &errorContext{
|
||||
data: NewData(),
|
||||
innr: err,
|
||||
err: stringError(msg),
|
||||
}
|
||||
}
|
||||
|
||||
// WrapMsgf wraps supplied error as inner, returning an ErrorContext with
|
||||
// a new outer error made from the supplied message format string
|
||||
func WrapMsgf(err error, msg string, a ...interface{}) ErrorContext {
|
||||
return WrapMsg(err, fmt.Sprintf(msg, a...))
|
||||
}
|
||||
|
||||
// ErrorData attempts fetch ErrorData from supplied error, returns nil otherwise
|
||||
func Data(err error) ErrorData {
|
||||
x, ok := err.(ErrorContext)
|
||||
if ok {
|
||||
return x.Data()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// stringError is the simplest ErrorContext implementation
|
||||
type stringError string
|
||||
|
||||
func (e stringError) Error() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e stringError) Is(err error) bool {
|
||||
se, ok := err.(stringError)
|
||||
return ok && e == se
|
||||
}
|
||||
|
||||
func (e stringError) Unwrap() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e stringError) Value(key string) (interface{}, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (e stringError) Append(kvs ...KV) ErrorContext {
|
||||
data := NewData()
|
||||
data.Append(kvs...)
|
||||
return &errorContext{
|
||||
data: data,
|
||||
innr: nil,
|
||||
err: e,
|
||||
}
|
||||
}
|
||||
|
||||
func (e stringError) Data() ErrorData {
|
||||
return nil
|
||||
}
|
||||
|
||||
// errorContext is the *actual* ErrorContext implementation
|
||||
type errorContext struct {
|
||||
// data contains any appended context data, there will only ever be one
|
||||
// instance of data within an ErrorContext stack
|
||||
data ErrorData
|
||||
|
||||
// innr is the inner wrapped error in this structure, it is only accessible
|
||||
// via .Unwrap() or via .Is()
|
||||
innr error
|
||||
|
||||
// err is the top-level error in this wrapping structure, we identify
|
||||
// as this error type via .Is() and return its error message
|
||||
err error
|
||||
}
|
||||
|
||||
func (e *errorContext) Error() string {
|
||||
return e.err.Error()
|
||||
}
|
||||
|
||||
func (e *errorContext) Is(err error) bool {
|
||||
return Is(e.err, err) || Is(e.innr, err)
|
||||
}
|
||||
|
||||
func (e *errorContext) Unwrap() error {
|
||||
return e.innr
|
||||
}
|
||||
|
||||
func (e *errorContext) Value(key string) (interface{}, bool) {
|
||||
return e.data.Value(key)
|
||||
}
|
||||
|
||||
func (e *errorContext) Append(kvs ...KV) ErrorContext {
|
||||
e.data.Append(kvs...)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *errorContext) Data() ErrorData {
|
||||
return e.data
|
||||
}
|
9
vendor/codeberg.org/gruf/go-fastpath/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-fastpath/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
vendor/codeberg.org/gruf/go-fastpath/README.md
generated
vendored
Normal file
1
vendor/codeberg.org/gruf/go-fastpath/README.md
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Alternative path library with a `strings.Builder` like path builder.
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
117
vendor/git.iim.gay/grufwub/fastpath/path.go → vendor/codeberg.org/gruf/go-fastpath/path.go
generated
vendored
117
vendor/git.iim.gay/grufwub/fastpath/path.go → vendor/codeberg.org/gruf/go-fastpath/path.go
generated
vendored
|
@ -4,20 +4,18 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
// allocate this just once
|
||||
var dot = []byte(".")
|
||||
// allocate these just once
|
||||
var (
|
||||
dot = []byte(".")
|
||||
dotStr = ".'"
|
||||
)
|
||||
|
||||
type Builder struct {
|
||||
noCopy noCopy
|
||||
|
||||
b []byte // b is the underlying byte buffer
|
||||
B []byte // B is the underlying byte buffer
|
||||
dd int // pos of last '..' appended to builder
|
||||
|
||||
abs bool // abs stores whether path passed to first .Append() is absolute
|
||||
set bool // set stores whether b.abs has been set i.e. not first call to .Append()
|
||||
|
||||
// lp int // pos of beginning of previous path segment
|
||||
// cp int // pos of beginning of current path segment
|
||||
}
|
||||
|
||||
// NewBuilder returns a new Builder object using the supplied byte
|
||||
|
@ -27,9 +25,7 @@ func NewBuilder(b []byte) Builder {
|
|||
b = b[:0]
|
||||
}
|
||||
return Builder{
|
||||
noCopy: noCopy{},
|
||||
|
||||
b: b,
|
||||
B: b,
|
||||
dd: 0,
|
||||
|
||||
abs: false,
|
||||
|
@ -39,22 +35,20 @@ func NewBuilder(b []byte) Builder {
|
|||
|
||||
// Reset resets the Builder object
|
||||
func (b *Builder) Reset() {
|
||||
b.b = b.b[:0]
|
||||
b.B = b.B[:0]
|
||||
b.dd = 0
|
||||
b.abs = false
|
||||
b.set = false
|
||||
// b.lp = 0
|
||||
// b.cp = 0
|
||||
}
|
||||
|
||||
// Len returns the number of accumulated bytes in the Builder
|
||||
func (b *Builder) Len() int {
|
||||
return len(b.b)
|
||||
return len(b.B)
|
||||
}
|
||||
|
||||
// Cap returns the capacity of the underlying Builder buffer
|
||||
func (b *Builder) Cap() int {
|
||||
return cap(b.b)
|
||||
return cap(b.B)
|
||||
}
|
||||
|
||||
// Bytes returns the accumulated path bytes.
|
||||
|
@ -62,15 +56,15 @@ func (b *Builder) Bytes() []byte {
|
|||
if b.Len() < 1 {
|
||||
return dot
|
||||
}
|
||||
return b.b
|
||||
return b.B
|
||||
}
|
||||
|
||||
// String returns the accumulated path string.
|
||||
func (b *Builder) String() string {
|
||||
if b.Len() < 1 {
|
||||
return string(dot)
|
||||
return dotStr
|
||||
}
|
||||
return string(b.b)
|
||||
return string(b.B)
|
||||
}
|
||||
|
||||
// StringPtr returns a ptr to the accumulated path string.
|
||||
|
@ -81,59 +75,17 @@ func (b *Builder) String() string {
|
|||
// this is undesired behaviour.
|
||||
func (b *Builder) StringPtr() string {
|
||||
if b.Len() < 1 {
|
||||
return *(*string)(unsafe.Pointer(&dot))
|
||||
return dotStr
|
||||
}
|
||||
return *(*string)(unsafe.Pointer(&b.b))
|
||||
return *(*string)(unsafe.Pointer(&b.B))
|
||||
}
|
||||
|
||||
// Basename returns the base name of the accumulated path string
|
||||
// func (b *Builder) Basename() string {
|
||||
// if b.cp >= b.Len() {
|
||||
// return dot
|
||||
// }
|
||||
// return deepcopy(b.string()[b.cp:])
|
||||
// }
|
||||
|
||||
// BasenamePtr returns a ptr to the base name of the accumulated
|
||||
// path string.
|
||||
//
|
||||
// Please note the underlying byte slice for this string is
|
||||
// tied to the builder, so any changes will result in the
|
||||
// returned string changing. Consider using .NewString() if
|
||||
// this is undesired behaviour.
|
||||
// func (b *Builder) BasenamePtr() string {
|
||||
// if b.cp >= b.Len() {
|
||||
// return dot
|
||||
// }
|
||||
// return b.string()[b.cp:]
|
||||
// }
|
||||
|
||||
// Dirname returns the dir path of the accumulated path string
|
||||
// func (b *Builder) Dirname() string {
|
||||
// if b.cp < 1 || b.cp-1 >= b.Len() {
|
||||
// return dot
|
||||
// }
|
||||
// return deepcopy(b.string()[:b.cp-1])
|
||||
// }
|
||||
|
||||
// DirnamePtr returns a ptr to the dir path of the accumulated
|
||||
// path string.
|
||||
//
|
||||
// Please note the underlying byte slice for this string is
|
||||
// tied to the builder, so any changes will result in the
|
||||
// returned string changing. Consider using .NewString() if
|
||||
// this is undesired behaviour.
|
||||
// func (b *Builder) DirnamePtr() string {
|
||||
// if b.cp < 1 || b.cp-1 >= b.Len() {
|
||||
// return dot
|
||||
// }
|
||||
// return b.String()[:b.cp-1]
|
||||
// }
|
||||
|
||||
// Absolute returns whether current path is absolute (not relative)
|
||||
func (b *Builder) Absolute() bool {
|
||||
return b.abs
|
||||
}
|
||||
|
||||
// SetAbsolute converts the current path to / from absolute
|
||||
func (b *Builder) SetAbsolute(val bool) {
|
||||
if !b.set {
|
||||
if val {
|
||||
|
@ -156,7 +108,7 @@ func (b *Builder) SetAbsolute(val bool) {
|
|||
// If not empty (i.e. not just '/'),
|
||||
// then shift bytes 1 left
|
||||
if b.Len() > 1 {
|
||||
copy(b.b, b.b[1:])
|
||||
copy(b.B, b.B[1:])
|
||||
}
|
||||
|
||||
// Truncate 1 byte. In the case of empty,
|
||||
|
@ -177,13 +129,13 @@ func (b *Builder) SetAbsolute(val bool) {
|
|||
|
||||
// Increase length
|
||||
l := b.Len()
|
||||
b.b = b.b[:l+1]
|
||||
b.B = b.B[:l+1]
|
||||
|
||||
// Shift bytes 1 right
|
||||
copy(b.b[1:], b.b[:l])
|
||||
copy(b.B[1:], b.B[:l])
|
||||
|
||||
// Set first byte '/'
|
||||
b.b[0] = '/'
|
||||
b.B[0] = '/'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +272,7 @@ func (b *Builder) Truncate(size int) {
|
|||
// truncate reduces the length of the buffer by the requested size,
|
||||
// no sanity checks are performed
|
||||
func (b *Builder) truncate(size int) {
|
||||
b.b = b.b[:b.Len()-size]
|
||||
b.B = b.B[:b.Len()-size]
|
||||
}
|
||||
|
||||
// guarantee ensures there is at least the requested size
|
||||
|
@ -329,8 +281,8 @@ func (b *Builder) truncate(size int) {
|
|||
func (b *Builder) guarantee(size int) {
|
||||
if size > b.Cap()-b.Len() {
|
||||
nb := make([]byte, 2*b.Cap()+size)
|
||||
copy(nb, b.b)
|
||||
b.b = nb[:b.Len()]
|
||||
copy(nb, b.B)
|
||||
b.B = nb[:b.Len()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -339,8 +291,8 @@ func (b *Builder) guarantee(size int) {
|
|||
// buffer and setting the next byte-at-index, this is safe as guarantee()
|
||||
// will have been called beforehand
|
||||
func (b *Builder) appendByte(c byte) {
|
||||
b.b = b.b[:b.Len()+1]
|
||||
b.b[b.Len()-1] = c
|
||||
b.B = b.B[:b.Len()+1]
|
||||
b.B[b.Len()-1] = c
|
||||
}
|
||||
|
||||
// appendSlice appends the supplied string slice to
|
||||
|
@ -352,8 +304,8 @@ func (b *Builder) appendByte(c byte) {
|
|||
func (b *Builder) appendSlice(slice string) int {
|
||||
i := 0
|
||||
for i < len(slice) && slice[i] != '/' {
|
||||
b.b = b.b[:b.Len()+1]
|
||||
b.b[b.Len()-1] = slice[i]
|
||||
b.B = b.B[:b.Len()+1]
|
||||
b.B[b.Len()-1] = slice[i]
|
||||
i++
|
||||
}
|
||||
return i
|
||||
|
@ -362,18 +314,13 @@ func (b *Builder) appendSlice(slice string) int {
|
|||
// backtrack reduces the end of the buffer back to the last
|
||||
// separating '/', or end of buffer
|
||||
func (b *Builder) backtrack() {
|
||||
b.b = b.b[:b.Len()-1]
|
||||
b.B = b.B[:b.Len()-1]
|
||||
|
||||
for b.Len()-1 > b.dd && b.b[b.Len()-1] != '/' {
|
||||
b.b = b.b[:b.Len()-1]
|
||||
for b.Len()-1 > b.dd && b.B[b.Len()-1] != '/' {
|
||||
b.B = b.B[:b.Len()-1]
|
||||
}
|
||||
|
||||
if b.Len() > 0 {
|
||||
b.b = b.b[:b.Len()-1]
|
||||
b.B = b.B[:b.Len()-1]
|
||||
}
|
||||
}
|
||||
|
||||
type noCopy struct{}
|
||||
|
||||
func (n *noCopy) Lock() {}
|
||||
func (n *noCopy) Unlock() {}
|
9
vendor/codeberg.org/gruf/go-hashenc/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-hashenc/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -3,7 +3,7 @@ package hashenc
|
|||
import (
|
||||
"hash"
|
||||
|
||||
"git.iim.gay/grufwub/go-bytes"
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
)
|
||||
|
||||
// HashEncoder defines an interface for calculating encoded hash sums of binary data
|
9
vendor/codeberg.org/gruf/go-logger/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-logger/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9
vendor/codeberg.org/gruf/go-logger/README.md
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-logger/README.md
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
Fast levelled logging package with customizable formatting.
|
||||
|
||||
Supports logging in 2 modes:
|
||||
- no locks, fastest possible logging, no guarantees for io.Writer thread safety
|
||||
- mutex locks during writes, still far faster than standard library logger
|
||||
|
||||
Running without locks isn't likely to cause you any issues*, but if it does, you can wrap your `io.Writer` using `AddSafety()` when instantiating your new Logger. Even when running the benchmarks, this library has no printing issues without locks, so in most cases you'll be fine, but the safety is there if you need it.
|
||||
|
||||
*most logging libraries advertising high speeds are likely not performing mutex locks, which is why with this library you have the option to opt-in/out of them.
|
21
vendor/codeberg.org/gruf/go-logger/clock.go
generated
vendored
Normal file
21
vendor/codeberg.org/gruf/go-logger/clock.go
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"codeberg.org/gruf/go-nowish"
|
||||
)
|
||||
|
||||
var (
|
||||
clock = nowish.Clock{}
|
||||
clockOnce = sync.Once{}
|
||||
)
|
||||
|
||||
// startClock starts the global nowish clock
|
||||
func startClock() {
|
||||
clockOnce.Do(func() {
|
||||
clock.Start(time.Millisecond * 10)
|
||||
clock.SetFormat("2006-01-02 15:04:05")
|
||||
})
|
||||
}
|
87
vendor/codeberg.org/gruf/go-logger/default.go
generated
vendored
Normal file
87
vendor/codeberg.org/gruf/go-logger/default.go
generated
vendored
Normal file
|
@ -0,0 +1,87 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
instance *Logger
|
||||
instanceOnce = sync.Once{}
|
||||
)
|
||||
|
||||
// Default returns the default Logger instance
|
||||
func Default() *Logger {
|
||||
instanceOnce.Do(func() { instance = New(os.Stdout) })
|
||||
return instance
|
||||
}
|
||||
|
||||
// Debug prints the provided arguments with the debug prefix to the global Logger instance
|
||||
func Debug(a ...interface{}) {
|
||||
Default().Debug(a...)
|
||||
}
|
||||
|
||||
// Debugf prints the provided format string and arguments with the debug prefix to the global Logger instance
|
||||
func Debugf(s string, a ...interface{}) {
|
||||
Default().Debugf(s, a...)
|
||||
}
|
||||
|
||||
// Info prints the provided arguments with the info prefix to the global Logger instance
|
||||
func Info(a ...interface{}) {
|
||||
Default().Info(a...)
|
||||
}
|
||||
|
||||
// Infof prints the provided format string and arguments with the info prefix to the global Logger instance
|
||||
func Infof(s string, a ...interface{}) {
|
||||
Default().Infof(s, a...)
|
||||
}
|
||||
|
||||
// Warn prints the provided arguments with the warn prefix to the global Logger instance
|
||||
func Warn(a ...interface{}) {
|
||||
Default().Warn(a...)
|
||||
}
|
||||
|
||||
// Warnf prints the provided format string and arguments with the warn prefix to the global Logger instance
|
||||
func Warnf(s string, a ...interface{}) {
|
||||
Default().Warnf(s, a...)
|
||||
}
|
||||
|
||||
// Error prints the provided arguments with the error prefix to the global Logger instance
|
||||
func Error(a ...interface{}) {
|
||||
Default().Error(a...)
|
||||
}
|
||||
|
||||
// Errorf prints the provided format string and arguments with the error prefix to the global Logger instance
|
||||
func Errorf(s string, a ...interface{}) {
|
||||
Default().Errorf(s, a...)
|
||||
}
|
||||
|
||||
// Fatal prints the provided arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1)
|
||||
func Fatal(a ...interface{}) {
|
||||
Default().Fatal(a...)
|
||||
}
|
||||
|
||||
// Fatalf prints the provided format string and arguments with the fatal prefix to the global Logger instance before exiting the program with os.Exit(1)
|
||||
func Fatalf(s string, a ...interface{}) {
|
||||
Default().Fatalf(s, a...)
|
||||
}
|
||||
|
||||
// Log prints the provided arguments with the supplied log level to the global Logger instance
|
||||
func Log(lvl LEVEL, a ...interface{}) {
|
||||
Default().Log(lvl, a...)
|
||||
}
|
||||
|
||||
// Logf prints the provided format string and arguments with the supplied log level to the global Logger instance
|
||||
func Logf(lvl LEVEL, s string, a ...interface{}) {
|
||||
Default().Logf(lvl, s, a...)
|
||||
}
|
||||
|
||||
// Print simply prints provided arguments to the global Logger instance
|
||||
func Print(a ...interface{}) {
|
||||
Default().Print(a...)
|
||||
}
|
||||
|
||||
// Printf simply prints provided the provided format string and arguments to the global Logger instance
|
||||
func Printf(s string, a ...interface{}) {
|
||||
Default().Printf(s, a...)
|
||||
}
|
231
vendor/codeberg.org/gruf/go-logger/entry.go
generated
vendored
Normal file
231
vendor/codeberg.org/gruf/go-logger/entry.go
generated
vendored
Normal file
|
@ -0,0 +1,231 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
)
|
||||
|
||||
// Entry defines an entry in the log
|
||||
type Entry struct {
|
||||
ctx context.Context
|
||||
lvl LEVEL
|
||||
buf *bytes.Buffer
|
||||
log *Logger
|
||||
}
|
||||
|
||||
// Context returns the current set Entry context.Context
|
||||
func (e *Entry) Context() context.Context {
|
||||
return e.ctx
|
||||
}
|
||||
|
||||
// WithContext updates Entry context value to the supplied
|
||||
func (e *Entry) WithContext(ctx context.Context) *Entry {
|
||||
e.ctx = ctx
|
||||
return e
|
||||
}
|
||||
|
||||
// Level appends the supplied level to the log entry, and sets the entry level.
|
||||
// Please note this CAN be called and append log levels multiple times
|
||||
func (e *Entry) Level(lvl LEVEL) *Entry {
|
||||
e.log.Format.AppendLevel(e.buf, lvl)
|
||||
e.buf.WriteByte(' ')
|
||||
e.lvl = lvl
|
||||
return e
|
||||
}
|
||||
|
||||
// Timestamp appends the current timestamp to the log entry. Please note this
|
||||
// CAN be called and append the timestamp multiple times
|
||||
func (e *Entry) Timestamp() *Entry {
|
||||
e.log.Format.AppendTimestamp(e.buf, clock.NowFormat())
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// TimestampIf performs Entry.Timestamp() only IF timestamping is enabled for the Logger.
|
||||
// Please note this CAN be called multiple times
|
||||
func (e *Entry) TimestampIf() *Entry {
|
||||
if e.log.Timestamp {
|
||||
e.Timestamp()
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// Hooks applies currently set Hooks to the Entry. Please note this CAN be
|
||||
// called and perform the Hooks multiple times
|
||||
func (e *Entry) Hooks() *Entry {
|
||||
for _, hook := range e.log.Hooks {
|
||||
hook.Do(e)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// Byte appends a byte value as key-value pair to the log entry
|
||||
func (e *Entry) Byte(key string, value byte) *Entry {
|
||||
e.log.Format.AppendByteField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Bytes appends a byte slice value as key-value pair to the log entry
|
||||
func (e *Entry) Bytes(key string, value []byte) *Entry {
|
||||
e.log.Format.AppendBytesField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Str appends a string value as key-value pair to the log entry
|
||||
func (e *Entry) Str(key string, value string) *Entry {
|
||||
e.log.Format.AppendStringField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Strs appends a string slice value as key-value pair to the log entry
|
||||
func (e *Entry) Strs(key string, value []string) *Entry {
|
||||
e.log.Format.AppendStringsField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Int appends an int value as key-value pair to the log entry
|
||||
func (e *Entry) Int(key string, value int) *Entry {
|
||||
e.log.Format.AppendIntField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Ints appends an int slice value as key-value pair to the log entry
|
||||
func (e *Entry) Ints(key string, value []int) *Entry {
|
||||
e.log.Format.AppendIntsField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Uint appends a uint value as key-value pair to the log entry
|
||||
func (e *Entry) Uint(key string, value uint) *Entry {
|
||||
e.log.Format.AppendUintField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Uints appends a uint slice value as key-value pair to the log entry
|
||||
func (e *Entry) Uints(key string, value []uint) *Entry {
|
||||
e.log.Format.AppendUintsField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Float appends a float value as key-value pair to the log entry
|
||||
func (e *Entry) Float(key string, value float64) *Entry {
|
||||
e.log.Format.AppendFloatField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Floats appends a float slice value as key-value pair to the log entry
|
||||
func (e *Entry) Floats(key string, value []float64) *Entry {
|
||||
e.log.Format.AppendFloatsField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Bool appends a bool value as key-value pair to the log entry
|
||||
func (e *Entry) Bool(key string, value bool) *Entry {
|
||||
e.log.Format.AppendBoolField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Bools appends a bool slice value as key-value pair to the log entry
|
||||
func (e *Entry) Bools(key string, value []bool) *Entry {
|
||||
e.log.Format.AppendBoolsField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Time appends a time.Time value as key-value pair to the log entry
|
||||
func (e *Entry) Time(key string, value time.Time) *Entry {
|
||||
e.log.Format.AppendTimeField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Times appends a time.Time slice value as key-value pair to the log entry
|
||||
func (e *Entry) Times(key string, value []time.Time) *Entry {
|
||||
e.log.Format.AppendTimesField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Duration appends a time.Duration value as key-value pair to the log entry
|
||||
func (e *Entry) Duration(key string, value time.Duration) *Entry {
|
||||
e.log.Format.AppendDurationField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Durations appends a time.Duration slice value as key-value pair to the log entry
|
||||
func (e *Entry) Durations(key string, value []time.Duration) *Entry {
|
||||
e.log.Format.AppendDurationsField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Field appends an interface value as key-value pair to the log entry
|
||||
func (e *Entry) Field(key string, value interface{}) *Entry {
|
||||
e.log.Format.AppendField(e.buf, key, value)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Fields appends a map of key-value pairs to the log entry
|
||||
func (e *Entry) Fields(fields map[string]interface{}) *Entry {
|
||||
e.log.Format.AppendFields(e.buf, fields)
|
||||
e.buf.WriteByte(' ')
|
||||
return e
|
||||
}
|
||||
|
||||
// Msg appends the formatted final message to the log and calls .Send()
|
||||
func (e *Entry) Msg(a ...interface{}) {
|
||||
e.log.Format.AppendMsg(e.buf, a...)
|
||||
e.Send()
|
||||
}
|
||||
|
||||
// Msgf appends the formatted final message to the log and calls .Send()
|
||||
func (e *Entry) Msgf(s string, a ...interface{}) {
|
||||
e.log.Format.AppendMsgf(e.buf, s, a...)
|
||||
e.Send()
|
||||
}
|
||||
|
||||
// Send triggers write of the log entry, skipping if the entry's log LEVEL
|
||||
// is below the currently set Logger level, and releases the Entry back to
|
||||
// the Logger's Entry pool. So it is NOT safe to continue using this Entry
|
||||
// object after calling .Send(), .Msg() or .Msgf()
|
||||
func (e *Entry) Send() {
|
||||
// If nothing to do, return
|
||||
if e.lvl < e.log.Level || e.buf.Len() < 1 {
|
||||
e.reset()
|
||||
return
|
||||
}
|
||||
|
||||
// Final new line
|
||||
if e.buf.B[e.buf.Len()-1] != '\n' {
|
||||
e.buf.WriteByte('\n')
|
||||
}
|
||||
|
||||
// Write, reset and release
|
||||
e.log.Output.Write(e.buf.B)
|
||||
e.reset()
|
||||
}
|
||||
|
||||
func (e *Entry) reset() {
|
||||
// Reset all
|
||||
e.ctx = nil
|
||||
e.buf.Reset()
|
||||
e.lvl = unset
|
||||
|
||||
// Release to pool
|
||||
e.log.pool.Put(e)
|
||||
}
|
640
vendor/codeberg.org/gruf/go-logger/format.go
generated
vendored
Normal file
640
vendor/codeberg.org/gruf/go-logger/format.go
generated
vendored
Normal file
|
@ -0,0 +1,640 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
)
|
||||
|
||||
// Check our types impl LogFormat
|
||||
var _ LogFormat = &TextFormat{}
|
||||
|
||||
// LogFormat defines a method of formatting log entries
|
||||
type LogFormat interface {
|
||||
AppendLevel(buf *bytes.Buffer, lvl LEVEL)
|
||||
AppendTimestamp(buf *bytes.Buffer, fmtNow string)
|
||||
AppendField(buf *bytes.Buffer, key string, value interface{})
|
||||
AppendFields(buf *bytes.Buffer, fields map[string]interface{})
|
||||
AppendByteField(buf *bytes.Buffer, key string, value byte)
|
||||
AppendBytesField(buf *bytes.Buffer, key string, value []byte)
|
||||
AppendStringField(buf *bytes.Buffer, key string, value string)
|
||||
AppendStringsField(buf *bytes.Buffer, key string, value []string)
|
||||
AppendBoolField(buf *bytes.Buffer, key string, value bool)
|
||||
AppendBoolsField(buf *bytes.Buffer, key string, value []bool)
|
||||
AppendIntField(buf *bytes.Buffer, key string, value int)
|
||||
AppendIntsField(buf *bytes.Buffer, key string, value []int)
|
||||
AppendUintField(buf *bytes.Buffer, key string, value uint)
|
||||
AppendUintsField(buf *bytes.Buffer, key string, value []uint)
|
||||
AppendFloatField(buf *bytes.Buffer, key string, value float64)
|
||||
AppendFloatsField(buf *bytes.Buffer, key string, value []float64)
|
||||
AppendTimeField(buf *bytes.Buffer, key string, value time.Time)
|
||||
AppendTimesField(buf *bytes.Buffer, key string, value []time.Time)
|
||||
AppendDurationField(buf *bytes.Buffer, key string, value time.Duration)
|
||||
AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration)
|
||||
AppendMsg(buf *bytes.Buffer, a ...interface{})
|
||||
AppendMsgf(buf *bytes.Buffer, s string, a ...interface{})
|
||||
}
|
||||
|
||||
// TextFormat is the default LogFormat implementation, with very similar formatting to logfmt
|
||||
type TextFormat struct {
|
||||
// Strict defines whether to use strict key-value pair formatting,
|
||||
// i.e. should the level, timestamp and msg be formatted as key-value pairs
|
||||
// or simply be printed as-is
|
||||
Strict bool
|
||||
|
||||
// Levels defines the map of log LEVELs to level strings this LogFormat will use
|
||||
Levels Levels
|
||||
}
|
||||
|
||||
// NewLogFmt returns a newly set LogFmt object, with DefaultLevels() set
|
||||
func NewLogFmt(strict bool) *TextFormat {
|
||||
return &TextFormat{
|
||||
Strict: strict,
|
||||
Levels: DefaultLevels(),
|
||||
}
|
||||
}
|
||||
|
||||
// appendReflectValue will safely append a reflected value
|
||||
func appendReflectValue(buf *bytes.Buffer, v reflect.Value, isKey bool) {
|
||||
switch v.Kind() {
|
||||
case reflect.Slice:
|
||||
appendSliceType(buf, v)
|
||||
case reflect.Map:
|
||||
appendMapType(buf, v)
|
||||
case reflect.Struct:
|
||||
appendStructType(buf, v)
|
||||
case reflect.Ptr:
|
||||
if v.IsNil() {
|
||||
appendNil(buf)
|
||||
} else {
|
||||
appendIface(buf, v.Elem().Interface(), isKey)
|
||||
}
|
||||
default:
|
||||
// Just print reflect string
|
||||
appendString(buf, v.String())
|
||||
}
|
||||
}
|
||||
|
||||
// appendKey should only be used in the case of directly setting key-value pairs,
|
||||
// not in the case of appendMapType, appendStructType
|
||||
func appendKey(buf *bytes.Buffer, key string) {
|
||||
if len(key) > 0 {
|
||||
// Only write key if here
|
||||
appendStringUnquoted(buf, key)
|
||||
buf.WriteByte('=')
|
||||
}
|
||||
}
|
||||
|
||||
// appendSlice performs provided fn and writes square brackets [] around it
|
||||
func appendSlice(buf *bytes.Buffer, fn func()) {
|
||||
buf.WriteByte('[')
|
||||
fn()
|
||||
buf.WriteByte(']')
|
||||
}
|
||||
|
||||
// appendMap performs provided fn and writes curly braces {} around it
|
||||
func appendMap(buf *bytes.Buffer, fn func()) {
|
||||
buf.WriteByte('{')
|
||||
fn()
|
||||
buf.WriteByte('}')
|
||||
}
|
||||
|
||||
// appendStruct performs provided fn and writes curly braces {} around it
|
||||
func appendStruct(buf *bytes.Buffer, fn func()) {
|
||||
buf.WriteByte('{')
|
||||
fn()
|
||||
buf.WriteByte('}')
|
||||
}
|
||||
|
||||
// appendNil writes a nil value placeholder to buf
|
||||
func appendNil(buf *bytes.Buffer) {
|
||||
buf.WriteString(`<nil>`)
|
||||
}
|
||||
|
||||
// appendByte writes a single byte to buf
|
||||
func appendByte(buf *bytes.Buffer, b byte) {
|
||||
buf.WriteByte(b)
|
||||
}
|
||||
|
||||
// appendBytes writes a quoted byte slice to buf
|
||||
func appendBytes(buf *bytes.Buffer, b []byte) {
|
||||
buf.WriteByte('"')
|
||||
buf.Write(b)
|
||||
buf.WriteByte('"')
|
||||
}
|
||||
|
||||
// appendBytesUnquoted writes a byte slice to buf as-is
|
||||
func appendBytesUnquoted(buf *bytes.Buffer, b []byte) {
|
||||
buf.Write(b)
|
||||
}
|
||||
|
||||
// appendString writes a quoted string to buf
|
||||
func appendString(buf *bytes.Buffer, s string) {
|
||||
buf.WriteByte('"')
|
||||
buf.WriteString(s)
|
||||
buf.WriteByte('"')
|
||||
}
|
||||
|
||||
// appendStringUnquoted writes a string as-is to buf
|
||||
func appendStringUnquoted(buf *bytes.Buffer, s string) {
|
||||
buf.WriteString(s)
|
||||
}
|
||||
|
||||
// appendStringSlice writes a slice of strings to buf
|
||||
func appendStringSlice(buf *bytes.Buffer, s []string) {
|
||||
appendSlice(buf, func() {
|
||||
for _, s := range s {
|
||||
appendString(buf, s)
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
if len(s) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendBool writes a formatted bool to buf
|
||||
func appendBool(buf *bytes.Buffer, b bool) {
|
||||
buf.B = strconv.AppendBool(buf.B, b)
|
||||
}
|
||||
|
||||
// appendBool writes a slice of formatted bools to buf
|
||||
func appendBoolSlice(buf *bytes.Buffer, b []bool) {
|
||||
appendSlice(buf, func() {
|
||||
// Write elements
|
||||
for _, b := range b {
|
||||
appendBool(buf, b)
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// Drop last comma
|
||||
if len(b) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendInt writes a formatted int to buf
|
||||
func appendInt(buf *bytes.Buffer, i int64) {
|
||||
buf.B = strconv.AppendInt(buf.B, i, 10)
|
||||
}
|
||||
|
||||
// appendIntSlice writes a slice of formatted int to buf
|
||||
func appendIntSlice(buf *bytes.Buffer, i []int) {
|
||||
appendSlice(buf, func() {
|
||||
// Write elements
|
||||
for _, i := range i {
|
||||
appendInt(buf, int64(i))
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// Drop last comma
|
||||
if len(i) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendUint writes a formatted uint to buf
|
||||
func appendUint(buf *bytes.Buffer, u uint64) {
|
||||
buf.B = strconv.AppendUint(buf.B, u, 10)
|
||||
}
|
||||
|
||||
// appendUintSlice writes a slice of formatted uint to buf
|
||||
func appendUintSlice(buf *bytes.Buffer, u []uint) {
|
||||
appendSlice(buf, func() {
|
||||
// Write elements
|
||||
for _, u := range u {
|
||||
appendUint(buf, uint64(u))
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// Drop last comma
|
||||
if len(u) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendFloat writes a formatted float to buf
|
||||
func appendFloat(buf *bytes.Buffer, f float64) {
|
||||
buf.B = strconv.AppendFloat(buf.B, f, 'G', -1, 64)
|
||||
}
|
||||
|
||||
// appendFloatSlice writes a slice formatted floats to buf
|
||||
func appendFloatSlice(buf *bytes.Buffer, f []float64) {
|
||||
appendSlice(buf, func() {
|
||||
// Write elements
|
||||
for _, f := range f {
|
||||
appendFloat(buf, f)
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// Drop last comma
|
||||
if len(f) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendTime writes a formatted, quoted time string to buf
|
||||
func appendTime(buf *bytes.Buffer, t time.Time) {
|
||||
buf.WriteByte('"')
|
||||
buf.B = t.AppendFormat(buf.B, time.RFC1123)
|
||||
buf.WriteByte('"')
|
||||
}
|
||||
|
||||
// appendTimeUnquoted writes a formatted time string to buf as-is
|
||||
func appendTimeUnquoted(buf *bytes.Buffer, t time.Time) {
|
||||
buf.B = t.AppendFormat(buf.B, time.RFC1123)
|
||||
}
|
||||
|
||||
// appendTimeSlice writes a slice of formatted time strings to buf
|
||||
func appendTimeSlice(buf *bytes.Buffer, t []time.Time) {
|
||||
appendSlice(buf, func() {
|
||||
// Write elements
|
||||
for _, t := range t {
|
||||
appendTime(buf, t)
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// Drop last comma
|
||||
if len(t) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendDuration writes a formatted, quoted duration string to buf
|
||||
func appendDuration(buf *bytes.Buffer, d time.Duration) {
|
||||
appendString(buf, d.String())
|
||||
}
|
||||
|
||||
// appendDurationUnquoted writes a formatted duration string to buf as-is
|
||||
func appendDurationUnquoted(buf *bytes.Buffer, d time.Duration) {
|
||||
appendStringUnquoted(buf, d.String())
|
||||
}
|
||||
|
||||
// appendDurationSlice writes a slice of formatted, quoted duration strings to buf
|
||||
func appendDurationSlice(buf *bytes.Buffer, d []time.Duration) {
|
||||
appendSlice(buf, func() {
|
||||
// Write elements
|
||||
for _, d := range d {
|
||||
appendString(buf, d.String())
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// Drop last comma
|
||||
if len(d) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendIface parses and writes a formatted interface value to buf
|
||||
func appendIface(buf *bytes.Buffer, i interface{}, isKey bool) {
|
||||
switch i := i.(type) {
|
||||
case nil:
|
||||
appendNil(buf)
|
||||
case byte:
|
||||
appendByte(buf, i)
|
||||
case []byte:
|
||||
if isKey {
|
||||
// Keys don't get quoted
|
||||
appendBytesUnquoted(buf, i)
|
||||
} else {
|
||||
appendBytes(buf, i)
|
||||
}
|
||||
case string:
|
||||
if isKey {
|
||||
// Keys don't get quoted
|
||||
appendStringUnquoted(buf, i)
|
||||
} else {
|
||||
appendString(buf, i)
|
||||
}
|
||||
case []string:
|
||||
appendStringSlice(buf, i)
|
||||
case int:
|
||||
appendInt(buf, int64(i))
|
||||
case int8:
|
||||
appendInt(buf, int64(i))
|
||||
case int16:
|
||||
appendInt(buf, int64(i))
|
||||
case int32:
|
||||
appendInt(buf, int64(i))
|
||||
case int64:
|
||||
appendInt(buf, i)
|
||||
case []int:
|
||||
appendIntSlice(buf, i)
|
||||
case uint:
|
||||
appendUint(buf, uint64(i))
|
||||
case uint16:
|
||||
appendUint(buf, uint64(i))
|
||||
case uint32:
|
||||
appendUint(buf, uint64(i))
|
||||
case uint64:
|
||||
appendUint(buf, i)
|
||||
case []uint:
|
||||
appendUintSlice(buf, i)
|
||||
case float32:
|
||||
appendFloat(buf, float64(i))
|
||||
case float64:
|
||||
appendFloat(buf, i)
|
||||
case []float64:
|
||||
appendFloatSlice(buf, i)
|
||||
case bool:
|
||||
appendBool(buf, i)
|
||||
case []bool:
|
||||
appendBoolSlice(buf, i)
|
||||
case time.Time:
|
||||
if isKey {
|
||||
// Keys don't get quoted
|
||||
appendTimeUnquoted(buf, i)
|
||||
} else {
|
||||
appendTime(buf, i)
|
||||
}
|
||||
case *time.Time:
|
||||
if isKey {
|
||||
// Keys don't get quoted
|
||||
appendTimeUnquoted(buf, *i)
|
||||
} else {
|
||||
appendTime(buf, *i)
|
||||
}
|
||||
case []time.Time:
|
||||
appendTimeSlice(buf, i)
|
||||
case time.Duration:
|
||||
if isKey {
|
||||
// Keys dont get quoted
|
||||
appendDurationUnquoted(buf, i)
|
||||
} else {
|
||||
appendDuration(buf, i)
|
||||
}
|
||||
case []time.Duration:
|
||||
appendDurationSlice(buf, i)
|
||||
case map[string]interface{}:
|
||||
appendIfaceMap(buf, i)
|
||||
case error:
|
||||
if isKey {
|
||||
// Keys don't get quoted
|
||||
appendStringUnquoted(buf, i.Error())
|
||||
} else {
|
||||
appendString(buf, i.Error())
|
||||
}
|
||||
case fmt.Stringer:
|
||||
if isKey {
|
||||
// Keys don't get quoted
|
||||
appendStringUnquoted(buf, i.String())
|
||||
} else {
|
||||
appendString(buf, i.String())
|
||||
}
|
||||
default:
|
||||
// If we reached here, we need reflection.
|
||||
appendReflectValue(buf, reflect.ValueOf(i), isKey)
|
||||
}
|
||||
}
|
||||
|
||||
// appendIfaceMap writes a map of key-value pairs (as a set of fields) to buf
|
||||
func appendIfaceMap(buf *bytes.Buffer, v map[string]interface{}) {
|
||||
appendMap(buf, func() {
|
||||
// Write map pairs!
|
||||
for key, value := range v {
|
||||
appendStringUnquoted(buf, key)
|
||||
buf.WriteByte('=')
|
||||
appendIface(buf, value, false)
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
|
||||
// Drop last space
|
||||
if len(v) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendSliceType writes a slice of unknown type (parsed by reflection) to buf
|
||||
func appendSliceType(buf *bytes.Buffer, v reflect.Value) {
|
||||
n := v.Len()
|
||||
appendSlice(buf, func() {
|
||||
for i := 0; i < n; i++ {
|
||||
appendIface(buf, v.Index(i).Interface(), false)
|
||||
buf.WriteByte(',')
|
||||
}
|
||||
|
||||
// Drop last comma
|
||||
if n > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendMapType writes a map of unknown types (parsed by reflection) to buf
|
||||
func appendMapType(buf *bytes.Buffer, v reflect.Value) {
|
||||
// Get a map iterator
|
||||
r := v.MapRange()
|
||||
n := v.Len()
|
||||
|
||||
// Now begin creating the map!
|
||||
appendMap(buf, func() {
|
||||
// Iterate pairs
|
||||
for r.Next() {
|
||||
appendIface(buf, r.Key().Interface(), true)
|
||||
buf.WriteByte('=')
|
||||
appendIface(buf, r.Value().Interface(), false)
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
|
||||
// Drop last space
|
||||
if n > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// appendStructType writes a struct (as a set of key-value fields) to buf
|
||||
func appendStructType(buf *bytes.Buffer, v reflect.Value) {
|
||||
// Get value type & no. fields
|
||||
t := v.Type()
|
||||
n := v.NumField()
|
||||
w := 0
|
||||
|
||||
// Iter and write struct fields
|
||||
appendStruct(buf, func() {
|
||||
for i := 0; i < n; i++ {
|
||||
vfield := v.Field(i)
|
||||
|
||||
// Check for unexported fields
|
||||
if !vfield.CanInterface() {
|
||||
continue
|
||||
}
|
||||
|
||||
// Append the struct member as field key-value
|
||||
appendStringUnquoted(buf, t.Field(i).Name)
|
||||
buf.WriteByte('=')
|
||||
appendIface(buf, vfield.Interface(), false)
|
||||
buf.WriteByte(' ')
|
||||
|
||||
// Iter written count
|
||||
w++
|
||||
}
|
||||
|
||||
// Drop last space
|
||||
if w > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendLevel(buf *bytes.Buffer, lvl LEVEL) {
|
||||
if f.Strict {
|
||||
// Strict format, append level key
|
||||
buf.WriteString(`level=`)
|
||||
buf.WriteString(f.Levels.LevelString(lvl))
|
||||
return
|
||||
}
|
||||
|
||||
// Write level string
|
||||
buf.WriteByte('[')
|
||||
buf.WriteString(f.Levels.LevelString(lvl))
|
||||
buf.WriteByte(']')
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendTimestamp(buf *bytes.Buffer, now string) {
|
||||
if f.Strict {
|
||||
// Strict format, use key and quote
|
||||
appendStringUnquoted(buf, `time`)
|
||||
buf.WriteByte('=')
|
||||
appendString(buf, now)
|
||||
return
|
||||
}
|
||||
|
||||
// Write time as-is
|
||||
appendStringUnquoted(buf, now)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendField(buf *bytes.Buffer, key string, value interface{}) {
|
||||
appendKey(buf, key)
|
||||
appendIface(buf, value, false)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendFields(buf *bytes.Buffer, fields map[string]interface{}) {
|
||||
// Append individual fields
|
||||
for key, value := range fields {
|
||||
appendKey(buf, key)
|
||||
appendIface(buf, value, false)
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
|
||||
// Drop last space
|
||||
if len(fields) > 0 {
|
||||
buf.Truncate(1)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendByteField(buf *bytes.Buffer, key string, value byte) {
|
||||
appendKey(buf, key)
|
||||
appendByte(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendBytesField(buf *bytes.Buffer, key string, value []byte) {
|
||||
appendKey(buf, key)
|
||||
appendBytes(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendStringField(buf *bytes.Buffer, key string, value string) {
|
||||
appendKey(buf, key)
|
||||
appendString(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendStringsField(buf *bytes.Buffer, key string, value []string) {
|
||||
appendKey(buf, key)
|
||||
appendStringSlice(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendBoolField(buf *bytes.Buffer, key string, value bool) {
|
||||
appendKey(buf, key)
|
||||
appendBool(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendBoolsField(buf *bytes.Buffer, key string, value []bool) {
|
||||
appendKey(buf, key)
|
||||
appendBoolSlice(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendIntField(buf *bytes.Buffer, key string, value int) {
|
||||
appendKey(buf, key)
|
||||
appendInt(buf, int64(value))
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendIntsField(buf *bytes.Buffer, key string, value []int) {
|
||||
appendKey(buf, key)
|
||||
appendIntSlice(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendUintField(buf *bytes.Buffer, key string, value uint) {
|
||||
appendKey(buf, key)
|
||||
appendUint(buf, uint64(value))
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendUintsField(buf *bytes.Buffer, key string, value []uint) {
|
||||
appendKey(buf, key)
|
||||
appendUintSlice(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendFloatField(buf *bytes.Buffer, key string, value float64) {
|
||||
appendKey(buf, key)
|
||||
appendFloat(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendFloatsField(buf *bytes.Buffer, key string, value []float64) {
|
||||
appendKey(buf, key)
|
||||
appendFloatSlice(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendTimeField(buf *bytes.Buffer, key string, value time.Time) {
|
||||
appendKey(buf, key)
|
||||
appendTime(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendTimesField(buf *bytes.Buffer, key string, value []time.Time) {
|
||||
appendKey(buf, key)
|
||||
appendTimeSlice(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendDurationField(buf *bytes.Buffer, key string, value time.Duration) {
|
||||
appendKey(buf, key)
|
||||
appendDuration(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendDurationsField(buf *bytes.Buffer, key string, value []time.Duration) {
|
||||
appendKey(buf, key)
|
||||
appendDurationSlice(buf, value)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendMsg(buf *bytes.Buffer, a ...interface{}) {
|
||||
if f.Strict {
|
||||
// Strict format, use key and quote
|
||||
buf.WriteString(`msg="`)
|
||||
fmt.Fprint(buf, a...)
|
||||
buf.WriteByte('"')
|
||||
return
|
||||
}
|
||||
|
||||
// Write message as-is
|
||||
fmt.Fprint(buf, a...)
|
||||
}
|
||||
|
||||
func (f *TextFormat) AppendMsgf(buf *bytes.Buffer, s string, a ...interface{}) {
|
||||
if f.Strict {
|
||||
// Strict format, use key and quote
|
||||
buf.WriteString(`msg="`)
|
||||
fmt.Fprintf(buf, s, a...)
|
||||
buf.WriteByte('"')
|
||||
return
|
||||
}
|
||||
|
||||
// Write message as-is
|
||||
fmt.Fprintf(buf, s, a...)
|
||||
}
|
13
vendor/codeberg.org/gruf/go-logger/hook.go
generated
vendored
Normal file
13
vendor/codeberg.org/gruf/go-logger/hook.go
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
package logger
|
||||
|
||||
// Hook defines a log Entry modifier
|
||||
type Hook interface {
|
||||
Do(*Entry)
|
||||
}
|
||||
|
||||
// HookFunc is a simple adapter to allow functions to satisfy the Hook interface
|
||||
type HookFunc func(*Entry)
|
||||
|
||||
func (hook HookFunc) Do(entry *Entry) {
|
||||
hook(entry)
|
||||
}
|
39
vendor/codeberg.org/gruf/go-logger/level.go
generated
vendored
Normal file
39
vendor/codeberg.org/gruf/go-logger/level.go
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
package logger
|
||||
|
||||
// LEVEL defines a level of logging
|
||||
type LEVEL uint8
|
||||
|
||||
// Available levels of logging.
|
||||
const (
|
||||
unset LEVEL = 255
|
||||
DEBUG LEVEL = 5
|
||||
INFO LEVEL = 10
|
||||
WARN LEVEL = 15
|
||||
ERROR LEVEL = 20
|
||||
FATAL LEVEL = 25
|
||||
)
|
||||
|
||||
var unknownLevel = "unknown"
|
||||
|
||||
// Levels defines a mapping of log LEVELs to formatted level strings
|
||||
type Levels map[LEVEL]string
|
||||
|
||||
// DefaultLevels returns the default set of log levels
|
||||
func DefaultLevels() Levels {
|
||||
return Levels{
|
||||
DEBUG: "debug",
|
||||
INFO: "info",
|
||||
WARN: "warn",
|
||||
ERROR: "error",
|
||||
FATAL: "fatal",
|
||||
}
|
||||
}
|
||||
|
||||
// LevelString fetches the appropriate level string for the provided level, or "unknown"
|
||||
func (l Levels) LevelString(lvl LEVEL) string {
|
||||
str, ok := l[lvl]
|
||||
if !ok {
|
||||
return unknownLevel
|
||||
}
|
||||
return str
|
||||
}
|
153
vendor/codeberg.org/gruf/go-logger/logger.go
generated
vendored
Normal file
153
vendor/codeberg.org/gruf/go-logger/logger.go
generated
vendored
Normal file
|
@ -0,0 +1,153 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
)
|
||||
|
||||
type Logger struct {
|
||||
// Hooks defines a list of hooks which are called before an entry
|
||||
// is written. This should NOT be modified while the Logger is in use
|
||||
Hooks []Hook
|
||||
|
||||
// Level is the current log LEVEL, entries at level below the
|
||||
// currently set level will not be output. This should NOT
|
||||
// be modified while the Logger is in use
|
||||
Level LEVEL
|
||||
|
||||
// Timestamp defines whether to automatically append timestamps
|
||||
// to entries written via Logger convience methods and specifically
|
||||
// Entry.TimestampIf(). This should NOT be modified while Logger in use
|
||||
Timestamp bool
|
||||
|
||||
// Format is the log entry LogFormat to use. This should NOT
|
||||
// be modified while the Logger is in use
|
||||
Format LogFormat
|
||||
|
||||
// BufferSize is the Entry buffer size to use when allocating
|
||||
// new Entry objects. This should be modified atomically
|
||||
BufSize int64
|
||||
|
||||
// Output is the log's output writer. This should NOT be
|
||||
// modified while the Logger is in use
|
||||
Output io.Writer
|
||||
|
||||
// entry pool
|
||||
pool sync.Pool
|
||||
}
|
||||
|
||||
// New returns a new Logger instance with defaults
|
||||
func New(out io.Writer) *Logger {
|
||||
return NewWith(0 /* all */, true, NewLogFmt(false), 512, out)
|
||||
}
|
||||
|
||||
// NewWith returns a new Logger instance with supplied configuration
|
||||
func NewWith(lvl LEVEL, timestamp bool, fmt LogFormat, bufsize int64, out io.Writer) *Logger {
|
||||
// Create new logger object
|
||||
log := &Logger{
|
||||
Level: lvl,
|
||||
Timestamp: timestamp,
|
||||
Format: fmt,
|
||||
BufSize: bufsize,
|
||||
Output: out,
|
||||
pool: sync.Pool{},
|
||||
}
|
||||
|
||||
// Ensure clock running
|
||||
startClock()
|
||||
|
||||
// Set-up logger Entry pool
|
||||
log.pool.New = func() interface{} {
|
||||
return &Entry{
|
||||
lvl: unset,
|
||||
buf: &bytes.Buffer{B: make([]byte, 0, atomic.LoadInt64(&log.BufSize))},
|
||||
log: log,
|
||||
}
|
||||
}
|
||||
|
||||
return log
|
||||
}
|
||||
|
||||
// Entry returns a new Entry from the Logger's pool with background context
|
||||
func (l *Logger) Entry() *Entry {
|
||||
return l.pool.Get().(*Entry).WithContext(context.Background())
|
||||
}
|
||||
|
||||
// Debug prints the provided arguments with the debug prefix
|
||||
func (l *Logger) Debug(a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(DEBUG).Hooks().Msg(a...)
|
||||
}
|
||||
|
||||
// Debugf prints the provided format string and arguments with the debug prefix
|
||||
func (l *Logger) Debugf(s string, a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(DEBUG).Hooks().Msgf(s, a...)
|
||||
}
|
||||
|
||||
// Info prints the provided arguments with the info prefix
|
||||
func (l *Logger) Info(a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(INFO).Hooks().Msg(a...)
|
||||
}
|
||||
|
||||
// Infof prints the provided format string and arguments with the info prefix
|
||||
func (l *Logger) Infof(s string, a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(INFO).Hooks().Msgf(s, a...)
|
||||
}
|
||||
|
||||
// Warn prints the provided arguments with the warn prefix
|
||||
func (l *Logger) Warn(a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(WARN).Hooks().Msg(a...)
|
||||
}
|
||||
|
||||
// Warnf prints the provided format string and arguments with the warn prefix
|
||||
func (l *Logger) Warnf(s string, a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(WARN).Hooks().Msgf(s, a...)
|
||||
}
|
||||
|
||||
// Error prints the provided arguments with the error prefix
|
||||
func (l *Logger) Error(a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(ERROR).Hooks().Msg(a...)
|
||||
}
|
||||
|
||||
// Errorf prints the provided format string and arguments with the error prefix
|
||||
func (l *Logger) Errorf(s string, a ...interface{}) {
|
||||
l.Entry().TimestampIf().Level(ERROR).Hooks().Msgf(s, a...)
|
||||
}
|
||||
|
||||
// Fatal prints provided arguments with the fatal prefix before exiting the program
|
||||
// with os.Exit(1)
|
||||
func (l *Logger) Fatal(a ...interface{}) {
|
||||
defer os.Exit(1)
|
||||
l.Entry().TimestampIf().Level(FATAL).Hooks().Msg(a...)
|
||||
}
|
||||
|
||||
// Fatalf prints provided the provided format string and arguments with the fatal prefix
|
||||
// before exiting the program with os.Exit(1)
|
||||
func (l *Logger) Fatalf(s string, a ...interface{}) {
|
||||
defer os.Exit(1)
|
||||
l.Entry().TimestampIf().Level(FATAL).Hooks().Msgf(s, a...)
|
||||
}
|
||||
|
||||
// Log prints the provided arguments with the supplied log level
|
||||
func (l *Logger) Log(lvl LEVEL, a ...interface{}) {
|
||||
l.Entry().TimestampIf().Hooks().Msg(a...)
|
||||
}
|
||||
|
||||
// Logf prints the provided format string and arguments with the supplied log level
|
||||
func (l *Logger) Logf(lvl LEVEL, s string, a ...interface{}) {
|
||||
l.Entry().TimestampIf().Hooks().Msgf(s, a...)
|
||||
}
|
||||
|
||||
// Print simply prints provided arguments
|
||||
func (l *Logger) Print(a ...interface{}) {
|
||||
l.Entry().Hooks().Msg(a...)
|
||||
}
|
||||
|
||||
// Printf simply prints provided the provided format string and arguments
|
||||
func (l *Logger) Printf(s string, a ...interface{}) {
|
||||
l.Entry().Hooks().Msgf(s, a...)
|
||||
}
|
|
@ -4,7 +4,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"git.iim.gay/grufwub/go-nowish"
|
||||
"codeberg.org/gruf/go-nowish"
|
||||
)
|
||||
|
||||
// TimeoutMutex defines a Mutex with timeouts on locks
|
9
vendor/codeberg.org/gruf/go-nowish/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-nowish/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3
vendor/codeberg.org/gruf/go-nowish/README.md
generated
vendored
Normal file
3
vendor/codeberg.org/gruf/go-nowish/README.md
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
a simple Go library with useful time utiities:
|
||||
- Clock: a high performance clock giving a good "ish" representation of "now" (hence the name!)
|
||||
- Timeout: a reusable structure for enforcing timeouts with a cancel
|
|
@ -28,11 +28,11 @@ type Clock struct {
|
|||
// because we want to minimize unnnecessary allocations
|
||||
mutex sync.Mutex
|
||||
|
||||
// Format is an unsafe pointer to the last-updated time format string
|
||||
Format unsafe.Pointer
|
||||
// nowfmt is an unsafe pointer to the last-updated time format string
|
||||
nowfmt unsafe.Pointer
|
||||
|
||||
// Time is an unsafe pointer to the last-updated time.Time object
|
||||
Time unsafe.Pointer
|
||||
// now is an unsafe pointer to the last-updated time.Time object
|
||||
now unsafe.Pointer
|
||||
}
|
||||
|
||||
// Start starts the clock with the provided precision, the
|
||||
|
@ -43,11 +43,11 @@ func (c *Clock) Start(precision time.Duration) func() {
|
|||
|
||||
// Set initial time
|
||||
t := time.Now()
|
||||
atomic.StorePointer(&c.Time, unsafe.Pointer(&t))
|
||||
atomic.StorePointer(&c.now, unsafe.Pointer(&t))
|
||||
|
||||
// Set initial format
|
||||
s := ""
|
||||
atomic.StorePointer(&c.Format, unsafe.Pointer(&s))
|
||||
atomic.StorePointer(&c.nowfmt, unsafe.Pointer(&s))
|
||||
|
||||
// If formatting string unset, set default
|
||||
c.mutex.Lock()
|
||||
|
@ -76,7 +76,7 @@ func (c *Clock) run(tick *time.Ticker) {
|
|||
|
||||
// Update time
|
||||
t := time.Now()
|
||||
atomic.StorePointer(&c.Time, unsafe.Pointer(&t))
|
||||
atomic.StorePointer(&c.now, unsafe.Pointer(&t))
|
||||
|
||||
// Invalidate format string
|
||||
atomic.StoreUint32(&c.valid, 0)
|
||||
|
@ -85,14 +85,14 @@ func (c *Clock) run(tick *time.Ticker) {
|
|||
|
||||
// Now returns a good (ish) estimate of the current 'now' time
|
||||
func (c *Clock) Now() time.Time {
|
||||
return *(*time.Time)(atomic.LoadPointer(&c.Time))
|
||||
return *(*time.Time)(atomic.LoadPointer(&c.now))
|
||||
}
|
||||
|
||||
// NowFormat returns the formatted "now" time, cached until next tick and "now" updates
|
||||
func (c *Clock) NowFormat() string {
|
||||
// If format still valid, return this
|
||||
if atomic.LoadUint32(&c.valid) == 1 {
|
||||
return *(*string)(atomic.LoadPointer(&c.Format))
|
||||
return *(*string)(atomic.LoadPointer(&c.nowfmt))
|
||||
}
|
||||
|
||||
// Get mutex lock
|
||||
|
@ -101,7 +101,7 @@ func (c *Clock) NowFormat() string {
|
|||
// Double check still invalid
|
||||
if atomic.LoadUint32(&c.valid) == 1 {
|
||||
c.mutex.Unlock()
|
||||
return *(*string)(atomic.LoadPointer(&c.Format))
|
||||
return *(*string)(atomic.LoadPointer(&c.nowfmt))
|
||||
}
|
||||
|
||||
// Calculate time format
|
||||
|
@ -111,7 +111,7 @@ func (c *Clock) NowFormat() string {
|
|||
)
|
||||
|
||||
// Update the stored value and set valid!
|
||||
atomic.StorePointer(&c.Format, unsafe.Pointer(&b))
|
||||
atomic.StorePointer(&c.nowfmt, unsafe.Pointer(&b))
|
||||
atomic.StoreUint32(&c.valid, 1)
|
||||
|
||||
// Unlock and return
|
|
@ -1,6 +1,7 @@
|
|||
package nowish
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
@ -9,73 +10,80 @@ import (
|
|||
type Timeout struct {
|
||||
noCopy noCopy //nolint noCopy because a copy will mess with atomics
|
||||
|
||||
tk *time.Ticker // tk is the underlying timeout-timer
|
||||
ch chan struct{} // ch is the cancel propagation channel
|
||||
tk *time.Timer // tk is the underlying timeout-timer
|
||||
ch syncer // ch is the cancel synchronization channel
|
||||
wg sync.WaitGroup // wg is the waitgroup to hold .Start() until timeout goroutine started
|
||||
st timeoutState // st stores the current timeout state (and protects concurrent use)
|
||||
}
|
||||
|
||||
// NewTimeout returns a new Timeout instance
|
||||
func NewTimeout() Timeout {
|
||||
tk := time.NewTicker(time.Minute)
|
||||
tk := time.NewTimer(time.Minute)
|
||||
tk.Stop() // don't keep it running
|
||||
return Timeout{
|
||||
tk: tk,
|
||||
ch: make(chan struct{}),
|
||||
ch: make(syncer),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Timeout) runTimeout(hook func()) {
|
||||
t.wg.Add(1)
|
||||
go func() {
|
||||
cancelled := false
|
||||
|
||||
// Signal started
|
||||
t.wg.Done()
|
||||
|
||||
select {
|
||||
// Timeout reached
|
||||
case <-t.tk.C:
|
||||
if !t.st.stop() /* a sneaky cancel! */ {
|
||||
t.ch.recv()
|
||||
cancelled = true
|
||||
defer t.ch.send()
|
||||
}
|
||||
|
||||
// Cancel called
|
||||
case <-t.ch:
|
||||
cancelled = true
|
||||
defer t.ch.send()
|
||||
}
|
||||
|
||||
// Ensure timer stopped
|
||||
if cancelled && !t.tk.Stop() {
|
||||
<-t.tk.C
|
||||
}
|
||||
|
||||
// Defer reset state
|
||||
defer t.st.reset()
|
||||
|
||||
// If timed out call hook
|
||||
if !cancelled {
|
||||
hook()
|
||||
}
|
||||
}()
|
||||
t.wg.Wait()
|
||||
}
|
||||
|
||||
// Start starts the timer with supplied timeout. If timeout is reached before
|
||||
// cancel then supplied timeout hook will be called. Error may be called if
|
||||
// Timeout is already running when this function is called
|
||||
func (t *Timeout) Start(d time.Duration, hook func()) {
|
||||
// Attempt to acquire start
|
||||
if !t.st.start() {
|
||||
panic("nowish: timeout already started")
|
||||
}
|
||||
|
||||
// Start the ticker
|
||||
t.runTimeout(hook)
|
||||
t.tk.Reset(d)
|
||||
|
||||
go func() {
|
||||
cancelled := false
|
||||
|
||||
select {
|
||||
// Timeout reached
|
||||
case <-t.tk.C:
|
||||
if !t.st.stop() {
|
||||
// cancel was called in the nick of time
|
||||
<-t.ch
|
||||
cancelled = true
|
||||
}
|
||||
|
||||
// Cancel called
|
||||
case <-t.ch:
|
||||
cancelled = true
|
||||
}
|
||||
|
||||
// Stop ticker
|
||||
t.tk.Stop()
|
||||
|
||||
// If timed out call hook
|
||||
if !cancelled {
|
||||
hook()
|
||||
}
|
||||
|
||||
// Finally, reset state
|
||||
t.st.reset()
|
||||
}()
|
||||
}
|
||||
|
||||
// Cancel cancels the currently running timer. If a cancel is achieved, then
|
||||
// this function will return after the timeout goroutine is finished
|
||||
func (t *Timeout) Cancel() {
|
||||
// Attempt to acquire stop
|
||||
if !t.st.stop() {
|
||||
return
|
||||
}
|
||||
|
||||
// Send a cancel signal
|
||||
t.ch <- struct{}{}
|
||||
t.ch.send()
|
||||
t.ch.recv()
|
||||
}
|
||||
|
||||
// timeoutState provides a thread-safe timeout state mechanism
|
||||
|
@ -95,3 +103,16 @@ func (t *timeoutState) stop() bool {
|
|||
func (t *timeoutState) reset() {
|
||||
atomic.StoreUint32((*uint32)(t), 0)
|
||||
}
|
||||
|
||||
// syncer provides helpful receiver methods for a synchronization channel
|
||||
type syncer (chan struct{})
|
||||
|
||||
// send blocks on sending an empty value down channel
|
||||
func (s syncer) send() {
|
||||
s <- struct{}{}
|
||||
}
|
||||
|
||||
// recv blocks on receiving (and dropping) empty value from channel
|
||||
func (s syncer) recv() {
|
||||
<-s
|
||||
}
|
9
vendor/codeberg.org/gruf/go-pools/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-pools/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2
vendor/codeberg.org/gruf/go-pools/README.md
generated
vendored
Normal file
2
vendor/codeberg.org/gruf/go-pools/README.md
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
A selection of type-defined `sync.Pool` implementations with redefined "getter" and "putter"
|
||||
methods to handle their appropriate types.
|
75
vendor/codeberg.org/gruf/go-pools/bufio.go
generated
vendored
Normal file
75
vendor/codeberg.org/gruf/go-pools/bufio.go
generated
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
package pools
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// BufioReaderPool is a pooled allocator for bufio.Reader objects
|
||||
type BufioReaderPool interface {
|
||||
// Get fetches a bufio.Reader from pool and resets to supplied reader
|
||||
Get(io.Reader) *bufio.Reader
|
||||
|
||||
// Put places supplied bufio.Reader back in pool
|
||||
Put(*bufio.Reader)
|
||||
}
|
||||
|
||||
// NewBufioReaderPool returns a newly instantiated bufio.Reader pool
|
||||
func NewBufioReaderPool(size int) BufioReaderPool {
|
||||
return &bufioReaderPool{
|
||||
Pool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
return bufio.NewReaderSize(nil, size)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// bufioReaderPool is our implementation of BufioReaderPool
|
||||
type bufioReaderPool struct{ sync.Pool }
|
||||
|
||||
func (p *bufioReaderPool) Get(r io.Reader) *bufio.Reader {
|
||||
br := p.Pool.Get().(*bufio.Reader)
|
||||
br.Reset(r)
|
||||
return br
|
||||
}
|
||||
|
||||
func (p *bufioReaderPool) Put(br *bufio.Reader) {
|
||||
br.Reset(nil)
|
||||
p.Pool.Put(br)
|
||||
}
|
||||
|
||||
// BufioWriterPool is a pooled allocator for bufio.Writer objects
|
||||
type BufioWriterPool interface {
|
||||
// Get fetches a bufio.Writer from pool and resets to supplied writer
|
||||
Get(io.Writer) *bufio.Writer
|
||||
|
||||
// Put places supplied bufio.Writer back in pool
|
||||
Put(*bufio.Writer)
|
||||
}
|
||||
|
||||
// NewBufioWriterPool returns a newly instantiated bufio.Writer pool
|
||||
func NewBufioWriterPool(size int) BufioWriterPool {
|
||||
return &bufioWriterPool{
|
||||
Pool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
return bufio.NewWriterSize(nil, size)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// bufioWriterPool is our implementation of BufioWriterPool
|
||||
type bufioWriterPool struct{ sync.Pool }
|
||||
|
||||
func (p *bufioWriterPool) Get(w io.Writer) *bufio.Writer {
|
||||
bw := p.Pool.Get().(*bufio.Writer)
|
||||
bw.Reset(w)
|
||||
return bw
|
||||
}
|
||||
|
||||
func (p *bufioWriterPool) Put(bw *bufio.Writer) {
|
||||
bw.Reset(nil)
|
||||
p.Pool.Put(bw)
|
||||
}
|
46
vendor/codeberg.org/gruf/go-pools/bytes.go
generated
vendored
Normal file
46
vendor/codeberg.org/gruf/go-pools/bytes.go
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
package pools
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
)
|
||||
|
||||
// BufferPool is a pooled allocator for bytes.Buffer objects
|
||||
type BufferPool interface {
|
||||
// Get fetches a bytes.Buffer from pool
|
||||
Get() *bytes.Buffer
|
||||
|
||||
// Put places supplied bytes.Buffer in pool
|
||||
Put(*bytes.Buffer)
|
||||
}
|
||||
|
||||
// NewBufferPool returns a newly instantiated bytes.Buffer pool
|
||||
func NewBufferPool(size int) BufferPool {
|
||||
return &bufferPool{
|
||||
pool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &bytes.Buffer{B: make([]byte, 0, size)}
|
||||
},
|
||||
},
|
||||
size: size,
|
||||
}
|
||||
}
|
||||
|
||||
// bufferPool is our implementation of BufferPool
|
||||
type bufferPool struct {
|
||||
pool sync.Pool
|
||||
size int
|
||||
}
|
||||
|
||||
func (p *bufferPool) Get() *bytes.Buffer {
|
||||
return p.pool.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
func (p *bufferPool) Put(buf *bytes.Buffer) {
|
||||
if buf.Cap() < p.size {
|
||||
return
|
||||
}
|
||||
buf.Reset()
|
||||
p.pool.Put(buf)
|
||||
}
|
46
vendor/codeberg.org/gruf/go-pools/fastpath.go
generated
vendored
Normal file
46
vendor/codeberg.org/gruf/go-pools/fastpath.go
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
package pools
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"codeberg.org/gruf/go-fastpath"
|
||||
)
|
||||
|
||||
// PathBuilderPool is a pooled allocator for fastpath.Builder objects
|
||||
type PathBuilderPool interface {
|
||||
// Get fetches a fastpath.Builder from pool
|
||||
Get() *fastpath.Builder
|
||||
|
||||
// Put places supplied fastpath.Builder back in pool
|
||||
Put(*fastpath.Builder)
|
||||
}
|
||||
|
||||
// NewPathBuilderPool returns a newly instantiated fastpath.Builder pool
|
||||
func NewPathBuilderPool(size int) PathBuilderPool {
|
||||
return &pathBuilderPool{
|
||||
pool: sync.Pool{
|
||||
New: func() interface{} {
|
||||
return &fastpath.Builder{B: make([]byte, 0, size)}
|
||||
},
|
||||
},
|
||||
size: size,
|
||||
}
|
||||
}
|
||||
|
||||
// pathBuilderPool is our implementation of PathBuilderPool
|
||||
type pathBuilderPool struct {
|
||||
pool sync.Pool
|
||||
size int
|
||||
}
|
||||
|
||||
func (p *pathBuilderPool) Get() *fastpath.Builder {
|
||||
return p.pool.Get().(*fastpath.Builder)
|
||||
}
|
||||
|
||||
func (p *pathBuilderPool) Put(pb *fastpath.Builder) {
|
||||
if pb.Cap() < p.size {
|
||||
return
|
||||
}
|
||||
pb.Reset()
|
||||
p.pool.Put(pb)
|
||||
}
|
9
vendor/codeberg.org/gruf/go-store/LICENSE
generated
vendored
Normal file
9
vendor/codeberg.org/gruf/go-store/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 gruf
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,11 +1,11 @@
|
|||
package kv
|
||||
|
||||
import (
|
||||
"git.iim.gay/grufwub/go-errors"
|
||||
"git.iim.gay/grufwub/go-store/storage"
|
||||
"codeberg.org/gruf/go-errors"
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
)
|
||||
|
||||
var ErrIteratorClosed = errors.Define("store/kv: iterator closed")
|
||||
var ErrIteratorClosed = errors.New("store/kv: iterator closed")
|
||||
|
||||
// KVIterator provides a read-only iterator to all the key-value
|
||||
// pairs in a KVStore. While the iterator is open the store is read
|
|
@ -3,10 +3,10 @@ package kv
|
|||
import (
|
||||
"io"
|
||||
|
||||
"git.iim.gay/grufwub/go-errors"
|
||||
"codeberg.org/gruf/go-errors"
|
||||
)
|
||||
|
||||
var ErrStateClosed = errors.Define("store/kv: state closed")
|
||||
var ErrStateClosed = errors.New("store/kv: state closed")
|
||||
|
||||
// StateRO provides a read-only window to the store. While this
|
||||
// state is active during the Read() function window, the entire
|
|
@ -4,9 +4,9 @@ import (
|
|||
"io"
|
||||
"sync"
|
||||
|
||||
"git.iim.gay/grufwub/go-mutexes"
|
||||
"git.iim.gay/grufwub/go-store/storage"
|
||||
"git.iim.gay/grufwub/go-store/util"
|
||||
"codeberg.org/gruf/go-mutexes"
|
||||
"codeberg.org/gruf/go-store/storage"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
)
|
||||
|
||||
// KVStore is a very simple, yet performant key-value store
|
|
@ -9,11 +9,11 @@ import (
|
|||
"sync"
|
||||
"syscall"
|
||||
|
||||
"git.iim.gay/grufwub/fastpath"
|
||||
"git.iim.gay/grufwub/go-bytes"
|
||||
"git.iim.gay/grufwub/go-errors"
|
||||
"git.iim.gay/grufwub/go-hashenc"
|
||||
"git.iim.gay/grufwub/go-store/util"
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
"codeberg.org/gruf/go-errors"
|
||||
"codeberg.org/gruf/go-hashenc"
|
||||
"codeberg.org/gruf/go-pools"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -86,6 +86,7 @@ type BlockStorage struct {
|
|||
nodePath string // nodePath is the joined root path + node path prefix
|
||||
config BlockConfig // cfg is the supplied configuration for this store
|
||||
hashPool sync.Pool // hashPool is this store's hashEncoder pool
|
||||
bufpool pools.BufferPool // bufpool is this store's bytes.Buffer pool
|
||||
|
||||
// NOTE:
|
||||
// BlockStorage does not need to lock each of the underlying block files
|
||||
|
@ -97,8 +98,8 @@ type BlockStorage struct {
|
|||
// OpenBlock opens a BlockStorage instance for given folder path and configuration
|
||||
func OpenBlock(path string, cfg *BlockConfig) (*BlockStorage, error) {
|
||||
// Acquire path builder
|
||||
pb := util.AcquirePathBuilder()
|
||||
defer util.ReleasePathBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
|
||||
// Clean provided path, ensure ends in '/' (should
|
||||
// be dir, this helps with file path trimming later)
|
||||
|
@ -137,6 +138,15 @@ func OpenBlock(path string, cfg *BlockConfig) (*BlockStorage, error) {
|
|||
return nil, errPathIsFile
|
||||
}
|
||||
|
||||
// Figure out the largest size for bufpool slices
|
||||
bufSz := encodedHashLen
|
||||
if bufSz < config.BlockSize {
|
||||
bufSz = config.BlockSize
|
||||
}
|
||||
if bufSz < config.WriteBufSize {
|
||||
bufSz = config.WriteBufSize
|
||||
}
|
||||
|
||||
// Return new BlockStorage
|
||||
return &BlockStorage{
|
||||
path: path,
|
||||
|
@ -148,6 +158,7 @@ func OpenBlock(path string, cfg *BlockConfig) (*BlockStorage, error) {
|
|||
return newHashEncoder()
|
||||
},
|
||||
},
|
||||
bufpool: pools.NewBufferPool(bufSz),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -156,8 +167,8 @@ func (st *BlockStorage) Clean() error {
|
|||
nodes := map[string]*node{}
|
||||
|
||||
// Acquire path builder
|
||||
pb := fastpath.AcquireBuilder()
|
||||
defer fastpath.ReleaseBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
|
||||
// Walk nodes dir for entries
|
||||
onceErr := errors.OnceError{}
|
||||
|
@ -184,8 +195,9 @@ func (st *BlockStorage) Clean() error {
|
|||
defer file.Close()
|
||||
|
||||
// Alloc new Node + acquire hash buffer for writes
|
||||
hbuf := util.AcquireBuffer(encodedHashLen)
|
||||
defer util.ReleaseBuffer(hbuf)
|
||||
hbuf := st.bufpool.Get()
|
||||
defer st.bufpool.Put(hbuf)
|
||||
hbuf.Guarantee(encodedHashLen)
|
||||
node := node{}
|
||||
|
||||
// Write file contents to node
|
||||
|
@ -301,12 +313,12 @@ func (st *BlockStorage) ReadStream(key string) (io.ReadCloser, error) {
|
|||
}
|
||||
defer file.Close()
|
||||
|
||||
// Alloc new Node + acquire hash buffer for writes
|
||||
hbuf := util.AcquireBuffer(encodedHashLen)
|
||||
defer util.ReleaseBuffer(hbuf)
|
||||
node := node{}
|
||||
// Acquire hash buffer for writes
|
||||
hbuf := st.bufpool.Get()
|
||||
defer st.bufpool.Put(hbuf)
|
||||
|
||||
// Write file contents to node
|
||||
node := node{}
|
||||
_, err = io.CopyBuffer(
|
||||
&nodeWriter{
|
||||
node: &node,
|
||||
|
@ -399,7 +411,7 @@ func (st *BlockStorage) WriteStream(key string, r io.Reader) error {
|
|||
loop:
|
||||
for !onceErr.IsSet() {
|
||||
// Fetch new buffer for this loop
|
||||
buf := util.AcquireBuffer(st.config.BlockSize)
|
||||
buf := st.bufpool.Get()
|
||||
buf.Grow(st.config.BlockSize)
|
||||
|
||||
// Read next chunk
|
||||
|
@ -408,10 +420,10 @@ loop:
|
|||
case nil, io.ErrUnexpectedEOF:
|
||||
// do nothing
|
||||
case io.EOF:
|
||||
util.ReleaseBuffer(buf)
|
||||
st.bufpool.Put(buf)
|
||||
break loop
|
||||
default:
|
||||
util.ReleaseBuffer(buf)
|
||||
st.bufpool.Put(buf)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -424,10 +436,10 @@ loop:
|
|||
// If already on disk, skip
|
||||
has, err := st.statBlock(sum.StringPtr())
|
||||
if err != nil {
|
||||
util.ReleaseBuffer(buf)
|
||||
st.bufpool.Put(buf)
|
||||
return err
|
||||
} else if has {
|
||||
util.ReleaseBuffer(buf)
|
||||
st.bufpool.Put(buf)
|
||||
continue loop
|
||||
}
|
||||
|
||||
|
@ -436,7 +448,7 @@ loop:
|
|||
go func() {
|
||||
// Defer buffer release + signal done
|
||||
defer func() {
|
||||
util.ReleaseBuffer(buf)
|
||||
st.bufpool.Put(buf)
|
||||
wg.Done()
|
||||
}()
|
||||
|
||||
|
@ -491,8 +503,8 @@ loop:
|
|||
defer file.Close()
|
||||
|
||||
// Acquire write buffer
|
||||
buf := util.AcquireBuffer(st.config.WriteBufSize)
|
||||
defer util.ReleaseBuffer(buf)
|
||||
buf := st.bufpool.Get()
|
||||
defer st.bufpool.Put(buf)
|
||||
buf.Grow(st.config.WriteBufSize)
|
||||
|
||||
// Finally, write data to file
|
||||
|
@ -559,8 +571,8 @@ func (st *BlockStorage) Remove(key string) error {
|
|||
// WalkKeys implements Storage.WalkKeys()
|
||||
func (st *BlockStorage) WalkKeys(opts *WalkKeysOptions) error {
|
||||
// Acquire path builder
|
||||
pb := fastpath.AcquireBuilder()
|
||||
defer fastpath.ReleaseBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
|
||||
// Walk dir for entries
|
||||
return util.WalkDir(pb, st.nodePath, func(npath string, fsentry fs.DirEntry) {
|
||||
|
@ -579,8 +591,8 @@ func (st *BlockStorage) nodePathForKey(key string) (string, error) {
|
|||
}
|
||||
|
||||
// Acquire path builder
|
||||
pb := util.AcquirePathBuilder()
|
||||
defer util.ReleasePathBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
|
||||
// Return joined + cleaned node-path
|
||||
return pb.Join(st.nodePath, key), nil
|
||||
|
@ -588,8 +600,8 @@ func (st *BlockStorage) nodePathForKey(key string) (string, error) {
|
|||
|
||||
// blockPathForKey calculates the block file path for supplied hash
|
||||
func (st *BlockStorage) blockPathForKey(hash string) string {
|
||||
pb := util.AcquirePathBuilder()
|
||||
defer util.ReleasePathBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
return pb.Join(st.blockPath, hash)
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import (
|
|||
"compress/zlib"
|
||||
"io"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/util"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
"github.com/golang/snappy"
|
||||
)
|
||||
|
|
@ -7,9 +7,9 @@ import (
|
|||
"path"
|
||||
"syscall"
|
||||
|
||||
"git.iim.gay/grufwub/fastpath"
|
||||
"git.iim.gay/grufwub/go-bytes"
|
||||
"git.iim.gay/grufwub/go-store/util"
|
||||
"codeberg.org/gruf/go-bytes"
|
||||
"codeberg.org/gruf/go-pools"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
)
|
||||
|
||||
// DefaultDiskConfig is the default DiskStorage configuration
|
||||
|
@ -70,14 +70,15 @@ func getDiskConfig(cfg *DiskConfig) DiskConfig {
|
|||
type DiskStorage struct {
|
||||
path string // path is the root path of this store
|
||||
dots int // dots is the "dotdot" count for the root store path
|
||||
bufp pools.BufferPool // bufp is the buffer pool for this DiskStorage
|
||||
config DiskConfig // cfg is the supplied configuration for this store
|
||||
}
|
||||
|
||||
// OpenFile opens a DiskStorage instance for given folder path and configuration
|
||||
func OpenFile(path string, cfg *DiskConfig) (*DiskStorage, error) {
|
||||
// Acquire path builder
|
||||
pb := util.AcquirePathBuilder()
|
||||
defer util.ReleasePathBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
|
||||
// Clean provided path, ensure ends in '/' (should
|
||||
// be dir, this helps with file path trimming later)
|
||||
|
@ -120,6 +121,7 @@ func OpenFile(path string, cfg *DiskConfig) (*DiskStorage, error) {
|
|||
return &DiskStorage{
|
||||
path: path,
|
||||
dots: util.CountDotdots(path),
|
||||
bufp: pools.NewBufferPool(config.WriteBufSize),
|
||||
config: config,
|
||||
}, nil
|
||||
}
|
||||
|
@ -215,8 +217,8 @@ func (st *DiskStorage) WriteStream(key string, r io.Reader) error {
|
|||
defer cFile.Close()
|
||||
|
||||
// Acquire write buffer
|
||||
buf := util.AcquireBuffer(st.config.WriteBufSize)
|
||||
defer util.ReleaseBuffer(buf)
|
||||
buf := st.bufp.Get()
|
||||
defer st.bufp.Put(buf)
|
||||
buf.Grow(st.config.WriteBufSize)
|
||||
|
||||
// Copy reader to file
|
||||
|
@ -251,8 +253,8 @@ func (st *DiskStorage) Remove(key string) error {
|
|||
// WalkKeys implements Storage.WalkKeys()
|
||||
func (st *DiskStorage) WalkKeys(opts *WalkKeysOptions) error {
|
||||
// Acquire path builder
|
||||
pb := fastpath.AcquireBuilder()
|
||||
defer fastpath.ReleaseBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
|
||||
// Walk dir for entries
|
||||
return util.WalkDir(pb, st.path, func(kpath string, fsentry fs.DirEntry) {
|
||||
|
@ -270,8 +272,8 @@ func (st *DiskStorage) WalkKeys(opts *WalkKeysOptions) error {
|
|||
// filepath checks and returns a formatted filepath for given key
|
||||
func (st *DiskStorage) filepath(key string) (string, error) {
|
||||
// Acquire path builder
|
||||
pb := util.AcquirePathBuilder()
|
||||
defer util.ReleasePathBuilder(pb)
|
||||
pb := util.GetPathBuilder()
|
||||
defer util.PutPathBuilder(pb)
|
||||
|
||||
// Calculate transformed key path
|
||||
key = st.config.Transform.KeyToPath(key)
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"syscall"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/util"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
)
|
||||
|
||||
const (
|
|
@ -4,7 +4,7 @@ import (
|
|||
"os"
|
||||
"syscall"
|
||||
|
||||
"git.iim.gay/grufwub/go-store/util"
|
||||
"codeberg.org/gruf/go-store/util"
|
||||
)
|
||||
|
||||
type lockableFile struct {
|
|
@ -6,7 +6,7 @@ import (
|
|||
"strings"
|
||||
"syscall"
|
||||
|
||||
"git.iim.gay/grufwub/fastpath"
|
||||
"codeberg.org/gruf/go-fastpath"
|
||||
)
|
||||
|
||||
var dotdot = "../"
|
||||
|
@ -47,8 +47,8 @@ func WalkDir(pb *fastpath.Builder, path string, walkFn func(string, fs.DirEntry)
|
|||
// CleanDirs traverses the dir tree of the supplied path, removing any folders with zero children
|
||||
func CleanDirs(path string) error {
|
||||
// Acquire builder
|
||||
pb := AcquirePathBuilder()
|
||||
defer ReleasePathBuilder(pb)
|
||||
pb := GetPathBuilder()
|
||||
defer PutPathBuilder(pb)
|
||||
|
||||
// Get dir entries
|
||||
entries, err := os.ReadDir(path)
|
20
vendor/codeberg.org/gruf/go-store/util/pool.go
generated
vendored
Normal file
20
vendor/codeberg.org/gruf/go-store/util/pool.go
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"codeberg.org/gruf/go-fastpath"
|
||||
"codeberg.org/gruf/go-pools"
|
||||
)
|
||||
|
||||
// pathBuilderPool is the global fastpath.Builder pool
|
||||
var pathBuilderPool = pools.NewPathBuilderPool(512)
|
||||
|
||||
// GetPathBuilder fetches a fastpath.Builder object from the pool
|
||||
func GetPathBuilder() *fastpath.Builder {
|
||||
return pathBuilderPool.Get()
|
||||
}
|
||||
|
||||
// PutPathBuilder places supplied fastpath.Builder back in the pool
|
||||
func PutPathBuilder(pb *fastpath.Builder) {
|
||||
pb.Reset()
|
||||
pathBuilderPool.Put(pb)
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
Alternative path library with a `strings.Builder` like path builder.
|
||||
|
||||
Benchmarks compared to `"path"`:
|
||||
|
||||
![benchmarks](https://git.iim.gay/grufwub/go-path/raw/main/benchmarks.png)
|
||||
|
||||
Better documentation + README in progress...
|
32
vendor/git.iim.gay/grufwub/fastpath/pool.go
vendored
32
vendor/git.iim.gay/grufwub/fastpath/pool.go
vendored
|
@ -1,32 +0,0 @@
|
|||
package fastpath
|
||||
|
||||
import "sync"
|
||||
|
||||
// 1/8 max unix path length
|
||||
const defaultBufSize = 512
|
||||
|
||||
var (
|
||||
builderPool sync.Pool
|
||||
once = sync.Once{}
|
||||
)
|
||||
|
||||
func pool() *sync.Pool {
|
||||
once.Do(func() {
|
||||
builderPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
builder := NewBuilder(make([]byte, defaultBufSize))
|
||||
return &builder
|
||||
},
|
||||
}
|
||||
})
|
||||
return &builderPool
|
||||
}
|
||||
|
||||
func AcquireBuilder() *Builder {
|
||||
return pool().Get().(*Builder)
|
||||
}
|
||||
|
||||
func ReleaseBuilder(b *Builder) {
|
||||
b.Reset()
|
||||
pool().Put(b)
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
Variable size bufferpool that supports storing buffers up to 512kb in size
|
||||
|
||||
See documentation for more information: https://godocs.io/git.iim.gay/grufwub/go-bufpool
|
||||
|
||||
Please note, the test here is a worst-case scenario for allocations (the size
|
||||
requests always increase so a new slice is always required)
|
File diff suppressed because one or more lines are too long
96
vendor/git.iim.gay/grufwub/go-bufpool/pool.go
vendored
96
vendor/git.iim.gay/grufwub/go-bufpool/pool.go
vendored
|
@ -1,96 +0,0 @@
|
|||
package bufpool
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"git.iim.gay/grufwub/go-bytes"
|
||||
)
|
||||
|
||||
// MAX returns the maximum possible sized slice that can be stored in a BufferPool
|
||||
func MAX() int {
|
||||
return log2Max
|
||||
}
|
||||
|
||||
// BufferPool is a variable sized buffer pool, separated into memory pages increasing
|
||||
// by powers of 2. This can offer large improvements over a sync.Pool designed to allocate
|
||||
// buffers of single sizes, or multiple buffer pools of differing allocation sizes
|
||||
type BufferPool struct {
|
||||
noCopy noCopy //nolint
|
||||
|
||||
// pools is a predefined-length array of sync.Pools, handling
|
||||
// ranges in capacity of 2**(n) --> 2**(n+1)
|
||||
pools [log2MaxPower + 1]sync.Pool
|
||||
once sync.Once
|
||||
}
|
||||
|
||||
// init simply sets the allocator funcs for each of the pools
|
||||
func (p *BufferPool) init() {
|
||||
for i := range p.pools {
|
||||
p.pools[i].New = func() interface{} {
|
||||
return &bytes.Buffer{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get retrieves a Buffer of at least supplied capacity from the pool,
|
||||
// allocating only if strictly necessary. If a capacity above the maximum
|
||||
// supported (see .MAX()) is requested, a slice is allocated with
|
||||
// expectance that it will just be dropped on call to .Put()
|
||||
func (p *BufferPool) Get(cap int) *bytes.Buffer {
|
||||
// If cap out of bounds, just alloc
|
||||
if cap < 2 || cap > log2Max {
|
||||
buf := bytes.NewBuffer(make([]byte, 0, cap))
|
||||
return &buf
|
||||
}
|
||||
|
||||
// Ensure initialized
|
||||
p.once.Do(p.init)
|
||||
|
||||
// Calculate page idx from log2 table
|
||||
pow := uint8(log2Table[cap])
|
||||
pool := &p.pools[pow-1]
|
||||
|
||||
// Attempt to fetch buf from pool
|
||||
buf := pool.Get().(*bytes.Buffer)
|
||||
|
||||
// Check of required capacity
|
||||
if buf.Cap() < cap {
|
||||
// We allocate via this method instead
|
||||
// of by buf.Guarantee() as this way we
|
||||
// can allocate only what the user requested.
|
||||
//
|
||||
// buf.Guarantee() can allocate alot more...
|
||||
buf.B = make([]byte, 0, cap)
|
||||
}
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
// Put resets and place the supplied Buffer back in its appropriate pool. Buffers
|
||||
// Buffers below or above maximum supported capacity (see .MAX()) will be dropped
|
||||
func (p *BufferPool) Put(buf *bytes.Buffer) {
|
||||
// Drop out of size range buffers
|
||||
if buf.Cap() < 2 || buf.Cap() > log2Max {
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure initialized
|
||||
p.once.Do(p.init)
|
||||
|
||||
// Calculate page idx from log2 table
|
||||
pow := uint8(log2Table[buf.Cap()])
|
||||
pool := &p.pools[pow-1]
|
||||
|
||||
// Reset, place in pool
|
||||
buf.Reset()
|
||||
pool.Put(buf)
|
||||
}
|
||||
|
||||
//nolint
|
||||
type noCopy struct{}
|
||||
|
||||
//nolint
|
||||
func (n *noCopy) Lock() {}
|
||||
|
||||
//nolint
|
||||
func (n *noCopy) Unlock() {}
|
39
vendor/git.iim.gay/grufwub/go-bytes/pool.go
vendored
39
vendor/git.iim.gay/grufwub/go-bytes/pool.go
vendored
|
@ -1,39 +0,0 @@
|
|||
package bytes
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type SizedBufferPool struct {
|
||||
pool sync.Pool
|
||||
len int
|
||||
cap int
|
||||
}
|
||||
|
||||
func (p *SizedBufferPool) Init(len, cap int) {
|
||||
p.pool.New = func() interface{} {
|
||||
buf := NewBuffer(make([]byte, len, cap))
|
||||
return &buf
|
||||
}
|
||||
p.len = len
|
||||
p.cap = cap
|
||||
}
|
||||
|
||||
func (p *SizedBufferPool) Acquire() *bytes.Buffer {
|
||||
return p.pool.Get().(*bytes.Buffer)
|
||||
}
|
||||
|
||||
func (p *SizedBufferPool) Release(buf *bytes.Buffer) {
|
||||
// If not enough cap, ignore
|
||||
if buf.Cap() < p.cap {
|
||||
return
|
||||
}
|
||||
|
||||
// Set length to expected
|
||||
buf.Reset()
|
||||
buf.Grow(p.len)
|
||||
|
||||
// Place in pool
|
||||
p.pool.Put(buf)
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
[![godocs.io](https://godocs.io/github.com/grufwub/go-errors?status.svg)](https://godocs.io/github.com/grufwub/go-errors)
|
||||
|
||||
An error library that allows wrapping of one error with another,
|
||||
extending with further information and preserving all wrapped errors
|
||||
for comparisons.
|
||||
|
||||
Where possible this library wraps standard errors library functions.
|
192
vendor/git.iim.gay/grufwub/go-errors/errors.go
vendored
192
vendor/git.iim.gay/grufwub/go-errors/errors.go
vendored
|
@ -1,192 +0,0 @@
|
|||
package errors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
_ Definition = definition("")
|
||||
_ Error = &derivedError{}
|
||||
)
|
||||
|
||||
// BaseError defines a simple error implementation
|
||||
type BaseError interface {
|
||||
// Error returns the error string
|
||||
Error() string
|
||||
|
||||
// Is checks whether an error is equal to this one
|
||||
Is(error) bool
|
||||
|
||||
// Unwrap attempts to unwrap any contained errors
|
||||
Unwrap() error
|
||||
}
|
||||
|
||||
// Definition describes an error implementation that allows creating
|
||||
// errors derived from this. e.g. global errors defined at runtime
|
||||
// that are called with `.New()` or `.Wrap()` to derive new errors with
|
||||
// extra contextual information when needed
|
||||
type Definition interface {
|
||||
// New returns a new Error based on Definition using
|
||||
// supplied string as contextual information
|
||||
New(a ...interface{}) Error
|
||||
|
||||
// Newf returns a new Error based on Definition using
|
||||
// supplied format string as contextual information
|
||||
Newf(string, ...interface{}) Error
|
||||
|
||||
// Wrap returns a new Error, wrapping supplied error with
|
||||
// a wrapper with definition as the outer error
|
||||
Wrap(error) Error
|
||||
|
||||
// must implement BaseError
|
||||
BaseError
|
||||
}
|
||||
|
||||
// Error defines an error implementation that supports wrapping errors, easily
|
||||
// accessing inner / outer errors in the wrapping structure, and setting extra
|
||||
// contextual information related to this error
|
||||
type Error interface {
|
||||
// Outer returns the outermost error
|
||||
Outer() error
|
||||
|
||||
// Extra allows you to set extra contextual information. Please note
|
||||
// that multiple calls to .Extra() will overwrite previously set information
|
||||
Extra(...interface{}) Error
|
||||
|
||||
// Extraf allows you to set extra contextual information using a format string.
|
||||
// Please note that multiple calls to .Extraf() will overwrite previously set
|
||||
// information
|
||||
Extraf(string, ...interface{}) Error
|
||||
|
||||
// must implement BaseError
|
||||
BaseError
|
||||
}
|
||||
|
||||
// New returns a simple error implementation. This exists so that `go-errors` can
|
||||
// be a drop-in replacement for the standard "errors" library
|
||||
func New(msg string) error {
|
||||
return definition(msg)
|
||||
}
|
||||
|
||||
// Define returns a new error Definition
|
||||
func Define(msg string) Definition {
|
||||
return definition(msg)
|
||||
}
|
||||
|
||||
// Wrap wraps the supplied inner error within a struct of the outer error
|
||||
func Wrap(outer, inner error) Error {
|
||||
// If this is a wrapped error but inner is nil, use this
|
||||
if derived, ok := outer.(*derivedError); ok && derived.inner == nil {
|
||||
derived.inner = inner
|
||||
return derived
|
||||
}
|
||||
|
||||
// Create new derived error
|
||||
return &derivedError{
|
||||
msg: "",
|
||||
extra: "",
|
||||
outer: outer,
|
||||
inner: inner,
|
||||
}
|
||||
}
|
||||
|
||||
type definition string
|
||||
|
||||
func (e definition) New(a ...interface{}) Error {
|
||||
return &derivedError{
|
||||
msg: fmt.Sprint(a...),
|
||||
extra: "",
|
||||
inner: nil,
|
||||
outer: e,
|
||||
}
|
||||
}
|
||||
|
||||
func (e definition) Newf(msg string, a ...interface{}) Error {
|
||||
return &derivedError{
|
||||
msg: fmt.Sprintf(msg, a...),
|
||||
extra: "",
|
||||
inner: nil,
|
||||
outer: e,
|
||||
}
|
||||
}
|
||||
|
||||
func (e definition) Wrap(err error) Error {
|
||||
return &derivedError{
|
||||
msg: "",
|
||||
extra: "",
|
||||
inner: err,
|
||||
outer: e,
|
||||
}
|
||||
}
|
||||
|
||||
func (e definition) Error() string {
|
||||
return string(e)
|
||||
}
|
||||
|
||||
func (e definition) Is(err error) bool {
|
||||
switch err := err.(type) {
|
||||
case definition:
|
||||
return e == err
|
||||
case *derivedError:
|
||||
return err.Is(e)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func (e definition) Unwrap() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type derivedError struct {
|
||||
msg string // msg provides the set message for this derived error
|
||||
extra string // extra provides any extra set contextual information
|
||||
inner error // inner is the error being wrapped
|
||||
outer error // outer is the outmost error in this wrapper
|
||||
}
|
||||
|
||||
func (e *derivedError) Error() string {
|
||||
// Error starts with outer error
|
||||
s := e.outer.Error() + ` (`
|
||||
|
||||
// Add any message
|
||||
if e.msg != "" {
|
||||
s += `msg="` + e.msg + `" `
|
||||
}
|
||||
|
||||
// Add any wrapped error
|
||||
if e.inner != nil {
|
||||
s += `wrapped="` + e.inner.Error() + `" `
|
||||
}
|
||||
|
||||
// Add any extra information
|
||||
if e.extra != "" {
|
||||
s += `extra="` + e.extra + `" `
|
||||
}
|
||||
|
||||
// Return error string
|
||||
return s[:len(s)-1] + `)`
|
||||
}
|
||||
|
||||
func (e *derivedError) Is(err error) bool {
|
||||
return errors.Is(e.outer, err) || errors.Is(e.inner, err)
|
||||
}
|
||||
|
||||
func (e *derivedError) Outer() error {
|
||||
return e.outer
|
||||
}
|
||||
|
||||
func (e *derivedError) Unwrap() error {
|
||||
return e.inner
|
||||
}
|
||||
|
||||
func (e *derivedError) Extra(a ...interface{}) Error {
|
||||
e.extra = fmt.Sprint(a...)
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *derivedError) Extraf(s string, a ...interface{}) Error {
|
||||
e.extra = fmt.Sprintf(s, a...)
|
||||
return e
|
||||
}
|
661
vendor/git.iim.gay/grufwub/go-mutexes/LICENSE
vendored
661
vendor/git.iim.gay/grufwub/go-mutexes/LICENSE
vendored
|
@ -1,661 +0,0 @@
|
|||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
|
@ -1,5 +0,0 @@
|
|||
nowish is a very simple library for creating Go clocks that give a good (ish)
|
||||
estimate of the "now" time, "ish" depending on the precision you request
|
||||
|
||||
similar to fastime, but more bare bones and using unsafe pointers instead of
|
||||
atomic value since we don't need to worry about type changes
|
|
@ -1,6 +0,0 @@
|
|||
package util
|
||||
|
||||
type NoCopy struct{}
|
||||
|
||||
func (*NoCopy) Lock() {}
|
||||
func (*NoCopy) Unlock() {}
|
|
@ -1,44 +0,0 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"git.iim.gay/grufwub/fastpath"
|
||||
"git.iim.gay/grufwub/go-bufpool"
|
||||
"git.iim.gay/grufwub/go-bytes"
|
||||
)
|
||||
|
||||
// pathBuilderPool is the global fastpath.Builder pool, we implement
|
||||
// our own here instead of using fastpath's default one because we
|
||||
// don't want to deal with fastpath's sync.Once locks on every Acquire/Release
|
||||
var pathBuilderPool = sync.Pool{
|
||||
New: func() interface{} {
|
||||
pb := fastpath.NewBuilder(make([]byte, 0, 512))
|
||||
return &pb
|
||||
},
|
||||
}
|
||||
|
||||
// AcquirePathBuilder returns a reset fastpath.Builder instance
|
||||
func AcquirePathBuilder() *fastpath.Builder {
|
||||
return pathBuilderPool.Get().(*fastpath.Builder)
|
||||
}
|
||||
|
||||
// ReleasePathBuilder resets and releases provided fastpath.Builder instance to global pool
|
||||
func ReleasePathBuilder(pb *fastpath.Builder) {
|
||||
pb.Reset()
|
||||
pathBuilderPool.Put(pb)
|
||||
}
|
||||
|
||||
// bufferPool is the global BufferPool, we implement this here
|
||||
// so we can share allocations across whatever libaries need them.
|
||||
var bufferPool = bufpool.BufferPool{}
|
||||
|
||||
// AcquireBuffer returns a reset bytes.Buffer with at least requested capacity
|
||||
func AcquireBuffer(cap int) *bytes.Buffer {
|
||||
return bufferPool.Get(cap)
|
||||
}
|
||||
|
||||
// ReleaseBuffer resets and releases provided bytes.Buffer to global BufferPool
|
||||
func ReleaseBuffer(buf *bytes.Buffer) {
|
||||
bufferPool.Put(buf)
|
||||
}
|
4
vendor/github.com/microcosm-cc/bluemonday/.editorconfig
generated
vendored
Normal file
4
vendor/github.com/microcosm-cc/bluemonday/.editorconfig
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
1
vendor/github.com/microcosm-cc/bluemonday/.gitattributes
generated
vendored
Normal file
1
vendor/github.com/microcosm-cc/bluemonday/.gitattributes
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
* text=auto eol=lf
|
3
vendor/github.com/microcosm-cc/bluemonday/CREDITS.md
generated
vendored
3
vendor/github.com/microcosm-cc/bluemonday/CREDITS.md
generated
vendored
|
@ -4,4 +4,5 @@
|
|||
1. Andrew Krasichkov @buglloc https://github.com/buglloc
|
||||
1. Mike Samuel mikesamuel@gmail.com
|
||||
1. Dmitri Shuralyov shurcooL@gmail.com
|
||||
1. https://github.com/opennota
|
||||
1. opennota https://github.com/opennota https://gitlab.com/opennota
|
||||
1. Tom Anthony https://www.tomanthony.co.uk/
|
8
vendor/github.com/microcosm-cc/bluemonday/Makefile
generated
vendored
8
vendor/github.com/microcosm-cc/bluemonday/Makefile
generated
vendored
|
@ -3,6 +3,7 @@
|
|||
# all: Builds the code locally after testing
|
||||
#
|
||||
# fmt: Formats the source files
|
||||
# fmt-check: Check if the source files are formated
|
||||
# build: Builds the code locally
|
||||
# vet: Vets the code
|
||||
# lint: Runs lint over the code (you do not need to fix everything)
|
||||
|
@ -11,6 +12,8 @@
|
|||
#
|
||||
# install: Builds, tests and installs the code locally
|
||||
|
||||
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")
|
||||
|
||||
.PHONY: all fmt build vet lint test cover install
|
||||
|
||||
# The first target is always the default action if `make` is called without
|
||||
|
@ -19,7 +22,10 @@
|
|||
all: fmt vet test install
|
||||
|
||||
fmt:
|
||||
@gofmt -s -w ./$*
|
||||
@gofmt -s -w ${GOFILES_NOVENDOR}
|
||||
|
||||
fmt-check:
|
||||
@([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1)
|
||||
|
||||
build:
|
||||
@go build
|
||||
|
|
6
vendor/github.com/microcosm-cc/bluemonday/README.md
generated
vendored
6
vendor/github.com/microcosm-cc/bluemonday/README.md
generated
vendored
|
@ -180,7 +180,7 @@ p.AllowElementsMatching(regex.MustCompile(`^my-element-`))
|
|||
|
||||
Or add elements as a virtue of adding an attribute:
|
||||
```go
|
||||
// Not the recommended pattern, see the recommendation on using .Matching() below
|
||||
// Note the recommended pattern, see the recommendation on using .Matching() below
|
||||
p.AllowAttrs("nowrap").OnElements("td", "th")
|
||||
```
|
||||
|
||||
|
@ -222,7 +222,7 @@ p.AllowElements("fieldset", "select", "option")
|
|||
|
||||
Although it's possible to handle inline CSS using `AllowAttrs` with a `Matching` rule, writing a single monolithic regular expression to safely process all inline CSS which you wish to allow is not a trivial task. Instead of attempting to do so, you can allow the `style` attribute on whichever element(s) you desire and use style policies to control and sanitize inline styles.
|
||||
|
||||
It is suggested that you use `Matching` (with a suitable regular expression)
|
||||
It is strongly recommended that you use `Matching` (with a suitable regular expression)
|
||||
`MatchingEnum`, or `MatchingHandler` to ensure each style matches your needs,
|
||||
but default handlers are supplied for most widely used styles.
|
||||
|
||||
|
@ -379,6 +379,8 @@ Both examples exhibit the same issue, they declare attributes but do not then sp
|
|||
|
||||
We are not yet including any tools to help allow and sanitize CSS. Which means that unless you wish to do the heavy lifting in a single regular expression (inadvisable), **you should not allow the "style" attribute anywhere**.
|
||||
|
||||
In the same theme, both `<script>` and `<style>` are considered harmful. These elements (and their content) will not be rendered by default, and require you to explicitly set `p.AllowUnsafe(true)`. You should be aware that allowing these elements defeats the purpose of using a HTML sanitizer as you would be explicitly allowing either JavaScript (and any plainly written XSS) and CSS (which can modify a DOM to insert JS), and additionally but limitations in this library mean it is not aware of whether HTML is validly structured and that can allow these elements to bypass some of the safety mechanisms built into the [WhatWG HTML parser standard](https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inselect).
|
||||
|
||||
It is not the job of bluemonday to fix your bad HTML, it is merely the job of bluemonday to prevent malicious HTML getting through. If you have mismatched HTML elements, or non-conforming nesting of elements, those will remain. But if you have well-structured HTML bluemonday will not break it.
|
||||
|
||||
## TODO
|
||||
|
|
30
vendor/github.com/microcosm-cc/bluemonday/policy.go
generated
vendored
30
vendor/github.com/microcosm-cc/bluemonday/policy.go
generated
vendored
|
@ -134,6 +134,19 @@ type Policy struct {
|
|||
setOfElementsMatchingAllowedWithoutAttrs []*regexp.Regexp
|
||||
|
||||
setOfElementsToSkipContent map[string]struct{}
|
||||
|
||||
// Permits fundamentally unsafe elements.
|
||||
//
|
||||
// If false (default) then elements such as `style` and `script` will not be
|
||||
// permitted even if declared in a policy. These elements when combined with
|
||||
// untrusted input cannot be safely handled by bluemonday at this point in
|
||||
// time.
|
||||
//
|
||||
// If true then `style` and `script` would be permitted by bluemonday if a
|
||||
// policy declares them. However this is not recommended under any circumstance
|
||||
// and can lead to XSS being rendered thus defeating the purpose of using a
|
||||
// HTML sanitizer.
|
||||
allowUnsafe bool
|
||||
}
|
||||
|
||||
type attrPolicy struct {
|
||||
|
@ -714,6 +727,23 @@ func (p *Policy) AllowElementsContent(names ...string) *Policy {
|
|||
return p
|
||||
}
|
||||
|
||||
// AllowUnsafe permits fundamentally unsafe elements.
|
||||
//
|
||||
// If false (default) then elements such as `style` and `script` will not be
|
||||
// permitted even if declared in a policy. These elements when combined with
|
||||
// untrusted input cannot be safely handled by bluemonday at this point in
|
||||
// time.
|
||||
//
|
||||
// If true then `style` and `script` would be permitted by bluemonday if a
|
||||
// policy declares them. However this is not recommended under any circumstance
|
||||
// and can lead to XSS being rendered thus defeating the purpose of using a
|
||||
// HTML sanitizer.
|
||||
func (p *Policy) AllowUnsafe(allowUnsafe bool) *Policy {
|
||||
p.init()
|
||||
p.allowUnsafe = allowUnsafe
|
||||
return p
|
||||
}
|
||||
|
||||
// addDefaultElementsWithoutAttrs adds the HTML elements that we know are valid
|
||||
// without any attributes to an internal map.
|
||||
// i.e. we know that <table> is valid, but <bdo> isn't valid as the "dir" attr
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue