From 82216281cee085771fa86173cdf6af6487e48512 Mon Sep 17 00:00:00 2001 From: tobi Date: Thu, 18 Sep 2025 16:48:45 +0200 Subject: [PATCH] [chore/docs] Fix Prometheus metric names for Gin, include example Grafana dash, update docs (#4443) # Description > If this is a code change, please include a summary of what you've coded, and link to the issue(s) it closes/implements. > > If this is a documentation change, please briefly describe what you've changed and why. This pull request updates some of our inconsistent metric naming, and adds an example Grafana dashboard using all the most up-to-date metrics names, and updates our docs to describe the latest way of setting up metrics. Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4362 Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4055 ## Checklist Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]` If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want). - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [x] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [x] I/we have performed a self-review of added code. - [x] I/we have written code that is legible and maintainable by others. - [x] I/we have commented the added code, particularly in hard-to-understand areas. - [x] I/we have made any necessary changes to documentation. - [ ] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [x] I/we have run `go fmt ./...` and `golangci-lint run`. Co-authored-by: kim Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4443 Reviewed-by: kim Co-authored-by: tobi Co-committed-by: tobi --- docs/advanced/metrics.md | 93 +- docs/advanced/tracing.md | 2 +- docs/configuration/observability.md | 50 - .../observability_and_metrics.md | 63 + docs/locales/zh/advanced/metrics.md | 2 +- docs/locales/zh/advanced/tracing.md | 2 +- ...bility.md => observability_and_metrics.md} | 0 docs/locales/zh/mkdocs.yml | 2 +- example/config.yaml | 40 +- example/gotosocial.service | 5 + .../metrics/gotosocial_grafana_dashboard.json | 1980 +++++++++ go.mod | 2 - go.sum | 4 - internal/observability/gin.go | 154 + internal/observability/metrics.go | 3 +- mkdocs.yml | 2 +- vendor/codeberg.org/gruf/go-bitutil/LICENSE | 9 - vendor/codeberg.org/gruf/go-bitutil/README.md | 3 - vendor/codeberg.org/gruf/go-bitutil/abs.go | 29 - vendor/codeberg.org/gruf/go-bitutil/flag.go | 3744 ----------------- vendor/codeberg.org/gruf/go-bitutil/flag.tpl | 117 - .../gruf/go-bitutil/flag_test.tpl | 98 - vendor/codeberg.org/gruf/go-bitutil/pack.go | 85 - vendor/codeberg.org/gruf/go-bitutil/test.tpl | 60 - .../technologize/otel-go-contrib/LICENSE | 201 - .../otel-go-contrib/otelginmetrics/config.go | 45 - .../otelginmetrics/middleware.go | 94 - .../otel-go-contrib/otelginmetrics/option.go | 74 - .../otelginmetrics/otelrecorder.go | 70 - .../otelginmetrics/recorder.go | 25 - .../otel-go-contrib/otelginmetrics/version.go | 11 - vendor/modules.txt | 6 - 32 files changed, 2315 insertions(+), 4760 deletions(-) delete mode 100644 docs/configuration/observability.md create mode 100644 docs/configuration/observability_and_metrics.md rename docs/locales/zh/configuration/{observability.md => observability_and_metrics.md} (100%) create mode 100644 example/metrics/gotosocial_grafana_dashboard.json create mode 100644 internal/observability/gin.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/LICENSE delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/README.md delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/abs.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/flag.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/flag.tpl delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/pack.go delete mode 100644 vendor/codeberg.org/gruf/go-bitutil/test.tpl delete mode 100644 vendor/github.com/technologize/otel-go-contrib/LICENSE delete mode 100644 vendor/github.com/technologize/otel-go-contrib/otelginmetrics/config.go delete mode 100644 vendor/github.com/technologize/otel-go-contrib/otelginmetrics/middleware.go delete mode 100644 vendor/github.com/technologize/otel-go-contrib/otelginmetrics/option.go delete mode 100644 vendor/github.com/technologize/otel-go-contrib/otelginmetrics/otelrecorder.go delete mode 100644 vendor/github.com/technologize/otel-go-contrib/otelginmetrics/recorder.go delete mode 100644 vendor/github.com/technologize/otel-go-contrib/otelginmetrics/version.go diff --git a/docs/advanced/metrics.md b/docs/advanced/metrics.md index 13eb84e46..91e94b4d2 100644 --- a/docs/advanced/metrics.md +++ b/docs/advanced/metrics.md @@ -1,32 +1,89 @@ # Metrics -GoToSocial comes with [OpenTelemetry][otel] based metrics. The metrics are exposed using the [Prometheus exposition format][prom] on the `/metrics` path. The configuration settings are documented in the [Observability configuration reference][obs]. +GoToSocial uses the [OpenTelemetry][otel] Go SDK to enable instance admins to expose runtime metrics in the Prometheus metrics format. -Currently the following metrics are collected: +Currently, the following metrics are collected: * Go performance and runtime metrics -* Gin (HTTP) metrics +* Gin (HTTP server) metrics * Bun (database) metrics -Metrics can be enable with the following configuration: +## Enabling metrics + +To enable metrics, first set the `metrics-enabled` configuration value to `true` in your config.yaml file: ```yaml metrics-enabled: true ``` -Though metrics do not contain anything privacy sensitive, you may not want to allow just anyone to view and scrape operational metrics of your instance. +Then, you will need to set some additional environment variables on the GoToSocial process in order to configure OpenTelemetry to expose metrics in the Prometheus format: + +```env +OTEL_METRICS_PRODUCERS=prometheus +OTEL_METRICS_EXPORTER=prometheus +``` + +By default, this configuration will instantiate an additional HTTP server running alongside the standard GoToSocial HTTP server, which exposes a Prometheus metrics endpoint at `localhost:9464/metrics`. + +!!! tip + If you are running GoToSocial using the [example systemd service definition](../../example/gotosocial.service), you can easily set these environment variables by uncommenting the relevant two lines in that file, and reloading + restarting the service. + +If you wish, you can further customize this metrics HTTP server by using the following environment variables to change the host and port: + +```env +OTEL_EXPORTER_PROMETHEUS_HOST=example.org +OTEL_EXPORTER_PROMETHEUS_PORT=9999 +``` + +## Serving metrics to the outside world + +If you have deployed GoToSocial in a "bare-metal" fashion without a reverse proxy, you can expose the metrics endpoint to the outside world by setting `OTEL_EXPORTER_PROMETHEUS_HOST` to your host value. For example, if your GtS instance `host` configuration value is set to `example.org`, you should set `OTEL_EXPORTER_PROMETHEUS_HOST=example.org`. You should then be able to access your metrics at `http://example.org:9464/metrics`. GoToSocial running in this fashion will not serve LetsEncrypt certificates at the metrics endpoint, so you will be limited to using HTTP rather than HTTPS. + +If you are using a reverse proxy like Nginx, you can expose the metrics endpoint to the outside world with HTTPS certificates, by putting an additional location stanza in your Nginx configuration above the catch-all `location /` stanza: + +```nginx +location /metrics { + proxy_pass http://127.0.0.1:9464; +} +``` + +This will instruct Nginx to forward requests to `example.org/metrics` to the separate Prometheus server running on port 9464. ## Enabling basic authentication -You can enable basic authentication for the metrics endpoint. On the GoToSocial, side you'll need the following configuration: +Although there is no sensitive data contained in the OTEL runtime statistics exported by Prometheus, you may nevertheless wish to gate access to the `/metrics` endpoint behind some kind of authentication, to prevent every Tom, Dick, and Harry from looking at your runtime stats. -```yaml -metrics-auth-enabled: true -metrics-auth-username: some_username -metrics-auth-password: some_password +You can do this by configuring your reverse proxy to require basic authentication for access to `/metrics`. + +In Nginx, for example, you could do this by creating an `htpasswd` file alongside your site in the `sites-available` directory of Nginx, and instructing Nginx to use that file to gate access. + +Assuming you followed the [guide for setting up Nginx as your reverse proxy](../getting_started/reverse_proxy/nginx.md), you will already have a file for your Nginx service definition at `/etc/nginx/sites-available/example.org`, where `example.org` is the hostname of your instance. + +You can create an `htpasswd` file alongside this file using the following command: + +```bash +htpasswd -c /etc/nginx/sites-available/example.org.htpasswd username ``` -You can scrape that endpoint with a Prometheus instance using the following configuration in your `scrape_configs`: +In the command, be sure to replace `example.org` with your hostname, and `username` with whatever username you want to use. + +Now, edit `/etc/nginx/sites-available/example.org` and update your `/metrics` stanza to use the `httpasswd` file. After editing it should look something like this: + +```nginx +location /metrics { + proxy_pass http://127.0.0.1:9464; + auth_basic "Metrics"; + auth_basic_user_file /etc/nginx/sites-available/example.org.htpasswd; +} +``` + +Again, replace `example.org` in that snippet with your instance hostname. + +When you're finished editing, reload + restart Nginx, and you should see a basic authentication prompt when visiting the `/metrics` endpoint of your instance in your browser. + +## Prometheus scrape configuration + +You can scrape your `/metrics` endpoint with a Prometheus instance using the following configuration in your `scrape_configs`: ```yaml - job_name: gotosocial @@ -40,18 +97,12 @@ You can scrape that endpoint with a Prometheus instance using the following conf - example.org ``` -## Blocking external scraping +Change `example.org` to your hostname in the above snippet. If you are not using HTTPS, change the `scheme` value to `http`. If you are not using basic authentication, you can remove the `basic_auth` section. If you are not using a reverse proxy, and metrics are exposed on port 9464, add the port to the host (eg., `example.org` -> `example.org:9464`). -When running with a reverse proxy you can use it to block external access to metrics. You can use this approach if your Prometheus scraper runs on the same machine as your GoToSocial instance and can thus access it internally. +## Viewing metrics on Grafana -For example with nginx, block the `/metrics` endpoint by returning a 404: - -```nginx -location /metrics { - return 404; -} -``` +Instructions on how to set up Grafana are beyond the scope of this document. However, once you have set up a Grafana to pull from your Prometheus instance, you can import the [example Grafana dashboard](https://codeberg.org/superseriousbusiness/gotosocial/raw/branch/main/example/metrics/gotosocial_grafana_dashboard.json) into your Grafana frontend to easily view GoToSocial Go runtime and HTTP metrics. [otel]: https://opentelemetry.io/ [prom]: https://prometheus.io/docs/instrumenting/exposition_formats/ -[obs]: ../configuration/observability.md \ No newline at end of file +[obs]: ../configuration/observability_and_metrics.md diff --git a/docs/advanced/tracing.md b/docs/advanced/tracing.md index 4e6dea2c7..46b9c884a 100644 --- a/docs/advanced/tracing.md +++ b/docs/advanced/tracing.md @@ -16,7 +16,7 @@ tracing-insecure-transport: true ``` [otel]: https://opentelemetry.io/ -[obs]: ../configuration/observability.md +[obs]: ../configuration/observability_and_metrics.md [tempo]: https://grafana.com/oss/tempo/ [grafana]: https://grafana.com/oss/grafana/ [ext]: https://codeberg.org/superseriousbusiness/gotosocial/tree/main/example/tracing diff --git a/docs/configuration/observability.md b/docs/configuration/observability.md deleted file mode 100644 index 0f1a420a4..000000000 --- a/docs/configuration/observability.md +++ /dev/null @@ -1,50 +0,0 @@ -# Observability - -These settings let you tune and configure certain observability related behaviours. - -GoToSocial uses OpenTelemetry. The metrics and trace exporters can be configured using the standard OpenTelemetry SDK environment variables. For a full reference, see [the OpenTelemetry docs](https://opentelemetry.io/docs/languages/sdk-configuration/). - -## Metrics - -Before enabling metrics, [read the guide](../advanced/metrics.md) and ensure you've taken the appropriate security measures for your setup. - -### Tracing - -To enable tracing, set `tracing-enabled` to `true`. - -Valid values for `OTEL_TRACES_EXPORTER` are [documented here](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_exporter). - -### Metrics - -To enable metrics, set `metrics-enabled` to `true`. By default this'll use OTLP to push metrics to an OpenTelemetry receiver. - -Valid values for `OTEL_METRICS_EXPORTER` are [documented here](https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_metrics_exporter) - -For Prometheus, set `OTEL_METRICS_EXPORTER` to `prometheus`. This will start a **second** HTTP server, bound for `localhost:9464` with the OpenTelemetry metrics. You can change this using: -* `OTEL_EXPORTER_PROMETHEUS_HOST` -* `OTEL_EXPORTER_PROMETHEUS_PORT` - -### Authentication - -If you want to expose the metrics with authentication, you'll need a reverse proxy. You can configure it to proxy to `http://localhost:9464/metrics` and handle authentication in your reverse proxy however you like. - -## Settings - -```yaml -################################## -##### OBSERVABILITY SETTINGS ##### -################################## - -# String. Header name to use to extract a request or trace ID from. Typically set by a -# loadbalancer or proxy. -# Default: "X-Request-Id" -request-id-header: "X-Request-Id" - -# Bool. Enable OpenTelemetry based tracing support. -# Default: false -tracing-enabled: false - -# Bool. Enable OpenTelemetry based metrics support. -# Default: false -metrics-enabled: false -``` \ No newline at end of file diff --git a/docs/configuration/observability_and_metrics.md b/docs/configuration/observability_and_metrics.md new file mode 100644 index 000000000..28ec4fb24 --- /dev/null +++ b/docs/configuration/observability_and_metrics.md @@ -0,0 +1,63 @@ +# Observability and Metrics + +These settings let you tune and configure certain observability related behaviours. + +GoToSocial uses OpenTelemetry. The metrics and trace exporters can be configured using the standard OpenTelemetry SDK environment variables. For a full reference, see [the OpenTelemetry docs](https://opentelemetry.io/docs/languages/sdk-configuration/). + +## Metrics + +Before enabling metrics, [read the guide](../advanced/metrics.md) and ensure you've taken the appropriate security measures for your setup. + +If you want to expose metrics with (basic) authentication, you'll need to do this with a reverse proxy. + +For more information and examples, see the [GtS metrics documentation](https://docs.gotosocial.org/en/latest/advanced/metrics/). + +## Settings + +```yaml +############################################## +##### OBSERVABILITY AND METRICS SETTINGS ##### +############################################## + +# String. Header name to use to extract a request or +# trace ID from. Typically set by a loadbalancer or proxy. +# +# Default: "X-Request-Id" +request-id-header: "X-Request-Id" + +# Bool. Enable OpenTelemetry based tracing support. +# +# When enabling tracing, you must also configure a traces +# exporter using the OTEL environment variable documented here: +# +# https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_exporter +# +# Default: false +tracing-enabled: false + +# Bool. Enable OpenTelemetry based metrics support. +# +# To expose Prometheus metrics, you must configure a metrics producer and +# a metrics exporter, using the OTEL environment variables documented here: +# +# https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport#NewMetricReader +# +# Typically, you will want to set the following environment variables +# (take note of the plural "producers" and singular "exporter"): +# +# - OTEL_METRICS_PRODUCERS=prometheus +# - OTEL_METRICS_EXPORTER=prometheus +# +# With these variables set, a Prometheus metrics endpoint will be exposed at +# localhost:9464/metrics. This can be further configured using the variables: +# +# - OTEL_EXPORTER_PROMETHEUS_HOST +# - OTEL_EXPORTER_PROMETHEUS_PORT +# +# For more information, see the GtS metrics documentation here: +# +# https://docs.gotosocial.org/en/latest/advanced/metrics/ +# +# Default: false +metrics-enabled: false +``` diff --git a/docs/locales/zh/advanced/metrics.md b/docs/locales/zh/advanced/metrics.md index a9110bf91..1984327cc 100644 --- a/docs/locales/zh/advanced/metrics.md +++ b/docs/locales/zh/advanced/metrics.md @@ -54,4 +54,4 @@ location /metrics { [otel]: https://opentelemetry.io/ [prom]: https://prometheus.io/docs/instrumenting/exposition_formats/ -[obs]: ../configuration/observability.md \ No newline at end of file +[obs]: ../configuration/observability_and_metrics.md \ No newline at end of file diff --git a/docs/locales/zh/advanced/tracing.md b/docs/locales/zh/advanced/tracing.md index 10e9f42fc..15e518330 100644 --- a/docs/locales/zh/advanced/tracing.md +++ b/docs/locales/zh/advanced/tracing.md @@ -16,7 +16,7 @@ tracing-insecure-transport: true ``` [otel]: https://opentelemetry.io/ -[obs]: ../configuration/observability.md +[obs]: ../configuration/observability_and_metrics.md [tempo]: https://grafana.com/oss/tempo/ [grafana]: https://grafana.com/oss/grafana/ [ext]: https://codeberg.org/superseriousbusiness/gotosocial/tree/main/example/tracing diff --git a/docs/locales/zh/configuration/observability.md b/docs/locales/zh/configuration/observability_and_metrics.md similarity index 100% rename from docs/locales/zh/configuration/observability.md rename to docs/locales/zh/configuration/observability_and_metrics.md diff --git a/docs/locales/zh/mkdocs.yml b/docs/locales/zh/mkdocs.yml index 94f8895ad..b7a237030 100644 --- a/docs/locales/zh/mkdocs.yml +++ b/docs/locales/zh/mkdocs.yml @@ -62,7 +62,7 @@ nav: - "configuration/syslog.md" - "configuration/httpclient.md" - "configuration/advanced.md" - - "configuration/observability.md" + - "configuration/observability_and_metrics.md" - "进阶": - "概述": "advanced/index.md" - "advanced/host-account-domain.md" diff --git a/example/config.yaml b/example/config.yaml index 3e7375627..9eaa560fe 100644 --- a/example/config.yaml +++ b/example/config.yaml @@ -1076,20 +1076,50 @@ syslog-protocol: "udp" # Default: "localhost:514" syslog-address: "localhost:514" -################################## -##### OBSERVABILITY SETTINGS ##### -################################## +############################################## +##### OBSERVABILITY AND METRICS SETTINGS ##### +############################################## -# String. Header name to use to extract a request or trace ID from. Typically set by a -# loadbalancer or proxy. +# String. Header name to use to extract a request or +# trace ID from. Typically set by a loadbalancer or proxy. +# # Default: "X-Request-Id" request-id-header: "X-Request-Id" # Bool. Enable OpenTelemetry based tracing support. +# +# When enabling tracing, you must also configure a traces +# exporter using the OTEL environment variable documented here: +# +# https://opentelemetry.io/docs/languages/sdk-configuration/general/#otel_traces_exporter +# # Default: false tracing-enabled: false # Bool. Enable OpenTelemetry based metrics support. +# +# To expose Prometheus metrics, you must configure a metrics producer and +# a metrics exporter, using the OTEL environment variables documented here: +# +# https://pkg.go.dev/go.opentelemetry.io/contrib/exporters/autoexport#NewMetricReader +# +# Typically, you will want to set the following environment variables +# (take note of the plural "producers" and singular "exporter"): +# +# - OTEL_METRICS_PRODUCERS=prometheus +# - OTEL_METRICS_EXPORTER=prometheus +# +# With these variables set, a Prometheus metrics endpoint will be exposed at +# localhost:9464/metrics. This can be further configured using the variables: +# +# - OTEL_EXPORTER_OTLP_METRICS_PROTOCOL +# - OTEL_EXPORTER_PROMETHEUS_HOST +# - OTEL_EXPORTER_PROMETHEUS_PORT +# +# For more information, see the GtS metrics documentation here: +# +# https://docs.gotosocial.org/en/latest/advanced/metrics/ +# # Default: false metrics-enabled: false diff --git a/example/gotosocial.service b/example/gotosocial.service index b59f6b5a6..48d14df8c 100644 --- a/example/gotosocial.service +++ b/example/gotosocial.service @@ -22,6 +22,11 @@ Restart=on-failure # Whatever you do, make sure the dir exists and that the gotosocial user has permission to write + read from it. #Environment="GTS_WAZERO_COMPILATION_CACHE=/gotosocial/.cache" +# If you have set `metrics-enabled` to `true` in your GoToSocial config file, and you want +# to expose Prometheus metrics at localhost:9464/metrics, uncomment the following two lines: +#Environment="OTEL_METRICS_EXPORTER=prometheus" +#Environment="OTEL_METRICS_PRODUCERS=prometheus" + # change if your path to the GoToSocial binary is different ExecStart=/gotosocial/gotosocial --config-path config.yaml server start WorkingDirectory=/gotosocial diff --git a/example/metrics/gotosocial_grafana_dashboard.json b/example/metrics/gotosocial_grafana_dashboard.json new file mode 100644 index 000000000..1a1b720db --- /dev/null +++ b/example/metrics/gotosocial_grafana_dashboard.json @@ -0,0 +1,1980 @@ +{ + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": {}, + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "12.0.1" + }, + { + "type": "panel", + "id": "histogram", + "name": "Histogram", + "version": "" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "timeseries", + "name": "Time series", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "huoding.com", + "type": "dashboard" + } + ] + }, + "description": "GoToSocial runtime metrics (filter by instance)", + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 28, + "panels": [], + "title": "GoToSocial Worker Metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 29, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_client_api_count{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A", + "useBackend": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + } + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_delivery_count{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_dereference_count{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_fedi_api_count{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "D", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_processing_count{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "E", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_webpush_count{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "F", + "useBackend": false + } + ], + "title": "Worker Counts", + "transformations": [ + { + "id": "renameByRegex", + "options": { + "regex": "gotosocial_workers_(.+)_count", + "renamePattern": "$1" + } + } + ], + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 24, + "x": 0, + "y": 4 + }, + "id": 30, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_client_api_queue{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "A", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_delivery_queue{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "interval": "", + "legendFormat": "{{__name__}}", + "range": true, + "refId": "B", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_dereference_queue{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "C", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_fedi_api_queue{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "D", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_processing_queue{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "E", + "useBackend": false + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "gotosocial_workers_webpush_queue{job=\"$job\", instance=~\"$instance\"}", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "{{__name__}}", + "range": true, + "refId": "F", + "useBackend": false + } + ], + "title": "Worker Queues", + "transformations": [ + { + "id": "renameByRegex", + "options": { + "regex": "gotosocial_workers_(.+)_queue", + "renamePattern": "$1" + } + } + ], + "type": "timeseries" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 31, + "panels": [], + "title": "GoToSocial HTTP Server Metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "decimals": 1, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 15 + }, + "id": 32, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "sum by(instance) (rate(http_server_requests_total{job=\"$job\", instance=~\"$instance\"}[$__rate_interval]))", + "fullMetaSearch": false, + "hide": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "B", + "useBackend": false + } + ], + "title": "Request rate (total)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 15 + }, + "id": 34, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "sum by (http_route, http_status_code) (rate(http_server_requests_total{instance=~\"$instance\", job=\"$job\", http_route=~\"/api.+\"}[$__rate_interval]))", + "instant": false, + "legendFormat": "{{http_route}} {{http_status_code}}", + "range": true, + "refId": "A" + } + ], + "title": "Request rate (client API)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 25 + }, + "id": 33, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "sum by (http_route, http_status_code) (rate(http_server_requests_total{instance=~\"$instance\", job=\"$job\", http_route=~\"/(.well-known|users).+\"}[$__rate_interval]))", + "instant": false, + "legendFormat": "{{http_route}} {{http_status_code}}", + "range": true, + "refId": "A" + } + ], + "title": "Request rate (federation endpoints)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "auto", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "reqps" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 25 + }, + "id": 35, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "editorMode": "code", + "expr": "sum by (http_route, http_status_code) (rate(http_server_requests_total{instance=~\"$instance\", job=\"$job\", http_route=~\"/fileserver.+\"}[$__rate_interval]))", + "instant": false, + "legendFormat": "{{http_route}} {{http_status_code}}", + "range": true, + "refId": "A" + } + ], + "title": "Request rate (fileserver)", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "stacking": { + "group": "A", + "mode": "none" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 0, + "y": 35 + }, + "id": 36, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "builder", + "expr": "histogram_quantile(0.95, sum by(le) (rate(http_server_duration_milliseconds_bucket{job=\"$job\", instance=~\"$instance\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + } + } + ], + "title": "Request latency p95", + "type": "histogram" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "fillOpacity": 80, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "lineWidth": 1, + "stacking": { + "group": "A", + "mode": "none" + } + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "ms" + }, + "overrides": [] + }, + "gridPos": { + "h": 10, + "w": 12, + "x": 12, + "y": 35 + }, + "id": 37, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "single", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "disableTextWrap": false, + "editorMode": "builder", + "expr": "histogram_quantile(0.99, sum by(le) (rate(http_server_duration_milliseconds_bucket{job=\"$job\", instance=~\"$instance\"}[$__rate_interval])))", + "fullMetaSearch": false, + "includeNullMetadata": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + } + } + ], + "title": "Request latency p99", + "type": "histogram" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 45 + }, + "id": 27, + "panels": [], + "title": "Go Runtime Metrics", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 46 + }, + "id": 26, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_mspan_inuse_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_mspan_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_mcache_inuse_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_mcache_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_buck_hash_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "E" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_gc_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "F" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_other_sys_bytes{job=\"$job\", instance=~\"$instance\"} - go_memstats_other_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "bytes of memory are used for other runtime allocations {instance={{instance}}}", + "refId": "G" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_next_gc_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "H" + } + ], + "title": "Memory in Off-Heap", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + } + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 46 + }, + "id": 12, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_heap_alloc_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "B" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_heap_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_heap_idle_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "C" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_heap_inuse_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "", + "refId": "D" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_heap_released_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "E" + } + ], + "title": "Memory in Heap", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 54 + }, + "id": 24, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_stack_inuse_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_stack_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "B" + } + ], + "title": "Memory in Stack", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 54 + }, + "id": 16, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_sys_bytes{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "title": "Total Used Memory", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 62 + }, + "id": 22, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_memstats_mallocs_total{job=\"$job\", instance=~\"$instance\"} - go_memstats_frees_total{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "title": "Number of Live Objects", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "description": "shows how many heap objects are allocated. This is a counter value so you can use rate() to objects allocated/s.", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 62 + }, + "id": 20, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "rate(go_memstats_mallocs_total{job=\"$job\", instance=~\"$instance\"}[1m])", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "title": "Rate of Objects Allocated", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 4, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "always", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "Bps" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 70 + }, + "id": 14, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "rate(go_memstats_alloc_bytes_total{job=\"$job\", instance=~\"$instance\"}[1m])", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "title": "Rates of Allocation", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "barWidthFactor": 0.6, + "drawStyle": "line", + "fillOpacity": 10, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": false, + "lineInterpolation": "linear", + "lineWidth": 1, + "pointSize": 5, + "scaleDistribution": { + "type": "linear" + }, + "showPoints": "never", + "spanNulls": false, + "stacking": { + "group": "A", + "mode": "none" + }, + "thresholdsStyle": { + "mode": "off" + } + }, + "links": [], + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green" + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "short" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 70 + }, + "id": 8, + "options": { + "alertThreshold": true, + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "hideZeros": false, + "mode": "multi", + "sort": "none" + } + }, + "pluginVersion": "12.0.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "expr": "go_goroutines{job=\"$job\", instance=~\"$instance\"}", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "title": "Goroutines", + "type": "timeseries" + } + ], + "refresh": "5s", + "schemaVersion": 41, + "tags": [ + "go", + "golang", + "gotosocial" + ], + "templating": { + "list": [ + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "definition": "label_values(go_goroutines, job)", + "includeAll": false, + "label": "job", + "name": "job", + "options": [], + "query": "label_values(go_goroutines, job)", + "refresh": 1, + "regex": "", + "type": "query" + }, + { + "current": {}, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "definition": "label_values(go_goroutines{job=\"$job\"}, instance)", + "includeAll": true, + "label": "instance", + "multi": true, + "name": "instance", + "options": [], + "query": "label_values(go_goroutines{job=\"$job\"}, instance)", + "refresh": 1, + "regex": "", + "type": "query" + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "GoToSocial Metrics", + "uid": "CgCw8jKZz", + "version": 9, + "weekStart": "" +} \ No newline at end of file diff --git a/go.mod b/go.mod index 115dde99e..8accf4398 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,6 @@ require ( code.superseriousbusiness.org/exif-terminator v0.11.0 code.superseriousbusiness.org/httpsig v1.4.0 code.superseriousbusiness.org/oauth2/v4 v4.5.4-0.20250812115401-3961e46a7384 - codeberg.org/gruf/go-bitutil v1.1.0 codeberg.org/gruf/go-bytesize v1.0.4 codeberg.org/gruf/go-byteutil v1.3.0 codeberg.org/gruf/go-cache/v3 v3.6.1 @@ -64,7 +63,6 @@ require ( github.com/spf13/viper v1.21.0 github.com/stretchr/testify v1.11.1 github.com/tdewolff/minify/v2 v2.24.3 - github.com/technologize/otel-go-contrib v1.1.1 github.com/temoto/robotstxt v1.1.2 github.com/tetratelabs/wazero v1.9.0 github.com/tomnomnom/linkheader v0.0.0-20250811210735-e5fe3b51442e diff --git a/go.sum b/go.sum index 9efbe092d..6b9b97d00 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,6 @@ code.superseriousbusiness.org/httpsig v1.4.0 h1:g9+KQMoTG0oR0II5gYb5pVVdNjbc7Cii code.superseriousbusiness.org/httpsig v1.4.0/go.mod h1:i2AKpj/WbA/o/UTvia9TAREzt0jP1AH3T1Uxjyhdzlw= code.superseriousbusiness.org/oauth2/v4 v4.5.4-0.20250812115401-3961e46a7384 h1:eJzULGUyhHGk2DdQxX/jbH9FKZOyoIF90p3dzukCfLA= code.superseriousbusiness.org/oauth2/v4 v4.5.4-0.20250812115401-3961e46a7384/go.mod h1:4x61i4C725jkXOpnUPFNfmiEthF6FZc/byADbalp+F8= -codeberg.org/gruf/go-bitutil v1.1.0 h1:U1Q+A1mtnPk+npqYrlRBc9ar2C5hYiBd17l1Wrp2Bt8= -codeberg.org/gruf/go-bitutil v1.1.0/go.mod h1:rGibFevYTQfYKcPv0Df5KpG8n5xC3AfD4d/UgYeoNy0= codeberg.org/gruf/go-bytesize v1.0.4 h1:LEojK46lUoE748Om7yldx6kLe6jCCuiytz5IZ8vH35g= codeberg.org/gruf/go-bytesize v1.0.4/go.mod h1:n/GU8HzL9f3UNp/mUKyr1qVmTlj7+xacpp0OHfkvLPs= codeberg.org/gruf/go-byteutil v1.3.0 h1:nRqJnCcRQ7xbfU6azw7zOzJrSMDIJHBqX6FL9vEMYmU= @@ -437,8 +435,6 @@ github.com/tdewolff/parse/v2 v2.8.3 h1:5VbvtJ83cfb289A1HzRA9sf02iT8YyUwN84ezjkdY github.com/tdewolff/parse/v2 v2.8.3/go.mod h1:Hwlni2tiVNKyzR1o6nUs4FOF07URA+JLBLd6dlIXYqo= github.com/tdewolff/test v1.0.11 h1:FdLbwQVHxqG16SlkGveC0JVyrJN62COWTRyUFzfbtBE= github.com/tdewolff/test v1.0.11/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8= -github.com/technologize/otel-go-contrib v1.1.1 h1:wZH9aSPNWZWIkEh3vfaKfMb15AJ80jJ1aVj/4GZdqIw= -github.com/technologize/otel-go-contrib v1.1.1/go.mod h1:dCN/wj2WyUO8aFZFdIN+6tfJHImjTML/8r2YVYAy3So= github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg= github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo= github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I= diff --git a/internal/observability/gin.go b/internal/observability/gin.go new file mode 100644 index 000000000..ca74ba06c --- /dev/null +++ b/internal/observability/gin.go @@ -0,0 +1,154 @@ +// GoToSocial +// Copyright (C) GoToSocial Authors admin@gotosocial.org +// SPDX-License-Identifier: AGPL-3.0-or-later +// +// 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 . + +//go:build !nootel + +package observability + +import ( + "net/http" + "slices" + "time" + + "code.superseriousbusiness.org/gotosocial/internal/config" + "github.com/gin-gonic/gin" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/metric" + semconv "go.opentelemetry.io/otel/semconv/v1.7.0" +) + +// ginMiddleware returns a middleware that +// records metrics for incoming requests. +func ginMiddleware() gin.HandlerFunc { + meter := otel.Meter("gin", metric.WithInstrumentationVersion(config.GetSoftwareVersion())) + + activeReqs, _ := meter.Int64UpDownCounter( + "http.server.requests_active", + metric.WithDescription("Number of requests currently active"), + ) + + totalReqs, _ := meter.Int64Counter( + "http.server.requests", + metric.WithDescription("Total number of requests served"), + ) + + reqSize, _ := meter.Int64Histogram( + "http.server.request_size", + metric.WithDescription("Request content length (approximate)"), + metric.WithUnit("bytes"), + ) + + respSize, _ := meter.Int64Histogram( + "http.server.response_size", + metric.WithDescription("Response content length"), + metric.WithUnit("bytes"), + ) + + duration, _ := meter.Int64Histogram( + "http.server.duration", + metric.WithDescription("Duration of request -> response"), + metric.WithUnit("ms"), + ) + + return func(c *gin.Context) { + + ctx := c.Request.Context() + route := c.FullPath() + start := time.Now() + + // Generate request attributes. + reqAttributes := []attribute.KeyValue{ + semconv.HTTPServerNameKey.String("GoToSocial"), + semconv.HTTPMethodKey.String(c.Request.Method), + semconv.HTTPRouteKey.String(route), + } + + // Increment active request count, + // decrement again when we're finished. + activeReqs.Add(ctx, 1, metric.WithAttributes(reqAttributes...)) + defer activeReqs.Add(ctx, -1, metric.WithAttributes(reqAttributes...)) + + // Process request so we can + // record response metrics. + c.Next() + + // Add HTTP response code to request + // attributes to create response attributes. + respAttributes := slices.Clone(reqAttributes) + respAttributes = append( + respAttributes, + semconv.HTTPStatusCodeKey.Int(c.Writer.Status()), + ) + + // Increment total requests. + totalReqs.Add(ctx, 1, metric.WithAttributes(respAttributes...)) + + // Record request size. + reqSize.Record( + ctx, + computeApproximateRequestSize(c.Request), + metric.WithAttributes(respAttributes...), + ) + + // Record response size. + respSize.Record( + ctx, + int64(c.Writer.Size()), + metric.WithAttributes(respAttributes...), + ) + + // Record req + resp duration. + duration.Record( + ctx, + time.Since(start).Milliseconds(), + metric.WithAttributes(respAttributes...), + ) + } +} + +func computeApproximateRequestSize(r *http.Request) (sz int64) { + len := func(s string) int64 { return int64(len(s)) } + + // First line + sz += len(r.Method) + if r.URL != nil { + sz += len(r.URL.Path) + sz++ // for '?' + sz += len(r.URL.RawQuery) + sz += len(r.URL.RawFragment) + } + sz += len(r.Proto) + sz += 2 // for '\r\n' + + // Next are lines for request headers. + for name, values := range r.Header { + + // Each value on its own line. + for _, value := range values { + sz += len(name) + sz += len(value) + sz += 2 // for '\r\n' + } + } + + // Finally, any request body (if set), + // this includes (multipart) form data. + sz += max(r.ContentLength, 0) + + return +} diff --git a/internal/observability/metrics.go b/internal/observability/metrics.go index 8df5fd9fb..4bca89c20 100644 --- a/internal/observability/metrics.go +++ b/internal/observability/metrics.go @@ -27,7 +27,6 @@ import ( "code.superseriousbusiness.org/gotosocial/internal/state" "github.com/gin-gonic/gin" - "github.com/technologize/otel-go-contrib/otelginmetrics" "go.opentelemetry.io/contrib/exporters/autoexport" "go.opentelemetry.io/contrib/instrumentation/runtime" "go.opentelemetry.io/otel" @@ -266,5 +265,5 @@ func InitializeMetrics(ctx context.Context, state *state.State) error { } func MetricsMiddleware() gin.HandlerFunc { - return otelginmetrics.Middleware(serviceName) + return ginMiddleware() } diff --git a/mkdocs.yml b/mkdocs.yml index 02dadf4cf..5c33d764e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -113,7 +113,7 @@ nav: - "configuration/syslog.md" - "configuration/httpclient.md" - "configuration/advanced.md" - - "configuration/observability.md" + - "configuration/observability_and_metrics.md" - "Advanced": - "Overview": "advanced/index.md" - "advanced/host-account-domain.md" diff --git a/vendor/codeberg.org/gruf/go-bitutil/LICENSE b/vendor/codeberg.org/gruf/go-bitutil/LICENSE deleted file mode 100644 index e4163ae35..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -MIT License - -Copyright (c) 2022 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. diff --git a/vendor/codeberg.org/gruf/go-bitutil/README.md b/vendor/codeberg.org/gruf/go-bitutil/README.md deleted file mode 100644 index a71c1aa0b..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# go-bitutil - -This library provides helpful methods and types for performing typical bitwise operations on integers, e.g. packing/unpacking, bit flags. \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-bitutil/abs.go b/vendor/codeberg.org/gruf/go-bitutil/abs.go deleted file mode 100644 index f4ce8ad75..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/abs.go +++ /dev/null @@ -1,29 +0,0 @@ -package bitutil - -// Abs8 returns the absolute value of i (calculated without branching). -func Abs8(i int8) int8 { - const bits = 8 - u := uint64(i >> (bits - 1)) - return (i ^ int8(u)) + int8(u&1) -} - -// Abs16 returns the absolute value of i (calculated without branching). -func Abs16(i int16) int16 { - const bits = 16 - u := uint64(i >> (bits - 1)) - return (i ^ int16(u)) + int16(u&1) -} - -// Abs32 returns the absolute value of i (calculated without branching). -func Abs32(i int32) int32 { - const bits = 32 - u := uint64(i >> (bits - 1)) - return (i ^ int32(u)) + int32(u&1) -} - -// Abs64 returns the absolute value of i (calculated without branching). -func Abs64(i int64) int64 { - const bits = 64 - u := uint64(i >> (bits - 1)) - return (i ^ int64(u)) + int64(u&1) -} diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag.go b/vendor/codeberg.org/gruf/go-bitutil/flag.go deleted file mode 100644 index 6a5b20d11..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/flag.go +++ /dev/null @@ -1,3744 +0,0 @@ -package bitutil - -import ( - "unsafe" -) - -// Flags8 is a type-casted unsigned integer with helper -// methods for easily managing up to 8 bit-flags. -type Flags8 uint8 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags8) Get(bit uint8) bool { - mask := Flags8(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags8) Set(bit uint8) Flags8 { - mask := Flags8(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags8) Unset(bit uint8) Flags8 { - mask := Flags8(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags8) Get0() bool { - const mask = Flags8(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags8) Set0() Flags8 { - const mask = Flags8(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags8) Unset0() Flags8 { - const mask = Flags8(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags8) Get1() bool { - const mask = Flags8(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags8) Set1() Flags8 { - const mask = Flags8(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags8) Unset1() Flags8 { - const mask = Flags8(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags8) Get2() bool { - const mask = Flags8(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags8) Set2() Flags8 { - const mask = Flags8(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags8) Unset2() Flags8 { - const mask = Flags8(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags8) Get3() bool { - const mask = Flags8(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags8) Set3() Flags8 { - const mask = Flags8(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags8) Unset3() Flags8 { - const mask = Flags8(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags8) Get4() bool { - const mask = Flags8(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags8) Set4() Flags8 { - const mask = Flags8(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags8) Unset4() Flags8 { - const mask = Flags8(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags8) Get5() bool { - const mask = Flags8(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags8) Set5() Flags8 { - const mask = Flags8(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags8) Unset5() Flags8 { - const mask = Flags8(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags8) Get6() bool { - const mask = Flags8(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags8) Set6() Flags8 { - const mask = Flags8(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags8) Unset6() Flags8 { - const mask = Flags8(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags8) Get7() bool { - const mask = Flags8(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags8) Set7() Flags8 { - const mask = Flags8(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags8) Unset7() Flags8 { - const mask = Flags8(1) << 7 - return f & ^mask -} - -// String returns a human readable representation of Flags8. -func (f Flags8) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 8) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags8. -func (f Flags8) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags8{") + (len("7=false ") * 8) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags8{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// Flags16 is a type-casted unsigned integer with helper -// methods for easily managing up to 16 bit-flags. -type Flags16 uint16 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags16) Get(bit uint8) bool { - mask := Flags16(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags16) Set(bit uint8) Flags16 { - mask := Flags16(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags16) Unset(bit uint8) Flags16 { - mask := Flags16(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags16) Get0() bool { - const mask = Flags16(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags16) Set0() Flags16 { - const mask = Flags16(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags16) Unset0() Flags16 { - const mask = Flags16(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags16) Get1() bool { - const mask = Flags16(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags16) Set1() Flags16 { - const mask = Flags16(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags16) Unset1() Flags16 { - const mask = Flags16(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags16) Get2() bool { - const mask = Flags16(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags16) Set2() Flags16 { - const mask = Flags16(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags16) Unset2() Flags16 { - const mask = Flags16(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags16) Get3() bool { - const mask = Flags16(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags16) Set3() Flags16 { - const mask = Flags16(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags16) Unset3() Flags16 { - const mask = Flags16(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags16) Get4() bool { - const mask = Flags16(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags16) Set4() Flags16 { - const mask = Flags16(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags16) Unset4() Flags16 { - const mask = Flags16(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags16) Get5() bool { - const mask = Flags16(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags16) Set5() Flags16 { - const mask = Flags16(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags16) Unset5() Flags16 { - const mask = Flags16(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags16) Get6() bool { - const mask = Flags16(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags16) Set6() Flags16 { - const mask = Flags16(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags16) Unset6() Flags16 { - const mask = Flags16(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags16) Get7() bool { - const mask = Flags16(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags16) Set7() Flags16 { - const mask = Flags16(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags16) Unset7() Flags16 { - const mask = Flags16(1) << 7 - return f & ^mask -} - -// Get8 will fetch the flag bit value at index 8. -func (f Flags16) Get8() bool { - const mask = Flags16(1) << 8 - return (f&mask != 0) -} - -// Set8 will set the flag bit value at index 8. -func (f Flags16) Set8() Flags16 { - const mask = Flags16(1) << 8 - return f | mask -} - -// Unset8 will unset the flag bit value at index 8. -func (f Flags16) Unset8() Flags16 { - const mask = Flags16(1) << 8 - return f & ^mask -} - -// Get9 will fetch the flag bit value at index 9. -func (f Flags16) Get9() bool { - const mask = Flags16(1) << 9 - return (f&mask != 0) -} - -// Set9 will set the flag bit value at index 9. -func (f Flags16) Set9() Flags16 { - const mask = Flags16(1) << 9 - return f | mask -} - -// Unset9 will unset the flag bit value at index 9. -func (f Flags16) Unset9() Flags16 { - const mask = Flags16(1) << 9 - return f & ^mask -} - -// Get10 will fetch the flag bit value at index 10. -func (f Flags16) Get10() bool { - const mask = Flags16(1) << 10 - return (f&mask != 0) -} - -// Set10 will set the flag bit value at index 10. -func (f Flags16) Set10() Flags16 { - const mask = Flags16(1) << 10 - return f | mask -} - -// Unset10 will unset the flag bit value at index 10. -func (f Flags16) Unset10() Flags16 { - const mask = Flags16(1) << 10 - return f & ^mask -} - -// Get11 will fetch the flag bit value at index 11. -func (f Flags16) Get11() bool { - const mask = Flags16(1) << 11 - return (f&mask != 0) -} - -// Set11 will set the flag bit value at index 11. -func (f Flags16) Set11() Flags16 { - const mask = Flags16(1) << 11 - return f | mask -} - -// Unset11 will unset the flag bit value at index 11. -func (f Flags16) Unset11() Flags16 { - const mask = Flags16(1) << 11 - return f & ^mask -} - -// Get12 will fetch the flag bit value at index 12. -func (f Flags16) Get12() bool { - const mask = Flags16(1) << 12 - return (f&mask != 0) -} - -// Set12 will set the flag bit value at index 12. -func (f Flags16) Set12() Flags16 { - const mask = Flags16(1) << 12 - return f | mask -} - -// Unset12 will unset the flag bit value at index 12. -func (f Flags16) Unset12() Flags16 { - const mask = Flags16(1) << 12 - return f & ^mask -} - -// Get13 will fetch the flag bit value at index 13. -func (f Flags16) Get13() bool { - const mask = Flags16(1) << 13 - return (f&mask != 0) -} - -// Set13 will set the flag bit value at index 13. -func (f Flags16) Set13() Flags16 { - const mask = Flags16(1) << 13 - return f | mask -} - -// Unset13 will unset the flag bit value at index 13. -func (f Flags16) Unset13() Flags16 { - const mask = Flags16(1) << 13 - return f & ^mask -} - -// Get14 will fetch the flag bit value at index 14. -func (f Flags16) Get14() bool { - const mask = Flags16(1) << 14 - return (f&mask != 0) -} - -// Set14 will set the flag bit value at index 14. -func (f Flags16) Set14() Flags16 { - const mask = Flags16(1) << 14 - return f | mask -} - -// Unset14 will unset the flag bit value at index 14. -func (f Flags16) Unset14() Flags16 { - const mask = Flags16(1) << 14 - return f & ^mask -} - -// Get15 will fetch the flag bit value at index 15. -func (f Flags16) Get15() bool { - const mask = Flags16(1) << 15 - return (f&mask != 0) -} - -// Set15 will set the flag bit value at index 15. -func (f Flags16) Set15() Flags16 { - const mask = Flags16(1) << 15 - return f | mask -} - -// Unset15 will unset the flag bit value at index 15. -func (f Flags16) Unset15() Flags16 { - const mask = Flags16(1) << 15 - return f & ^mask -} - -// String returns a human readable representation of Flags16. -func (f Flags16) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 16) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags16. -func (f Flags16) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags16{") + (len("15=false ") * 16) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags16{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], "8=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], "9=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], "10=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], "11=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], "12=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], "13=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], "14=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], "15=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// Flags32 is a type-casted unsigned integer with helper -// methods for easily managing up to 32 bit-flags. -type Flags32 uint32 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags32) Get(bit uint8) bool { - mask := Flags32(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags32) Set(bit uint8) Flags32 { - mask := Flags32(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags32) Unset(bit uint8) Flags32 { - mask := Flags32(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags32) Get0() bool { - const mask = Flags32(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags32) Set0() Flags32 { - const mask = Flags32(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags32) Unset0() Flags32 { - const mask = Flags32(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags32) Get1() bool { - const mask = Flags32(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags32) Set1() Flags32 { - const mask = Flags32(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags32) Unset1() Flags32 { - const mask = Flags32(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags32) Get2() bool { - const mask = Flags32(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags32) Set2() Flags32 { - const mask = Flags32(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags32) Unset2() Flags32 { - const mask = Flags32(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags32) Get3() bool { - const mask = Flags32(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags32) Set3() Flags32 { - const mask = Flags32(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags32) Unset3() Flags32 { - const mask = Flags32(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags32) Get4() bool { - const mask = Flags32(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags32) Set4() Flags32 { - const mask = Flags32(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags32) Unset4() Flags32 { - const mask = Flags32(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags32) Get5() bool { - const mask = Flags32(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags32) Set5() Flags32 { - const mask = Flags32(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags32) Unset5() Flags32 { - const mask = Flags32(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags32) Get6() bool { - const mask = Flags32(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags32) Set6() Flags32 { - const mask = Flags32(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags32) Unset6() Flags32 { - const mask = Flags32(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags32) Get7() bool { - const mask = Flags32(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags32) Set7() Flags32 { - const mask = Flags32(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags32) Unset7() Flags32 { - const mask = Flags32(1) << 7 - return f & ^mask -} - -// Get8 will fetch the flag bit value at index 8. -func (f Flags32) Get8() bool { - const mask = Flags32(1) << 8 - return (f&mask != 0) -} - -// Set8 will set the flag bit value at index 8. -func (f Flags32) Set8() Flags32 { - const mask = Flags32(1) << 8 - return f | mask -} - -// Unset8 will unset the flag bit value at index 8. -func (f Flags32) Unset8() Flags32 { - const mask = Flags32(1) << 8 - return f & ^mask -} - -// Get9 will fetch the flag bit value at index 9. -func (f Flags32) Get9() bool { - const mask = Flags32(1) << 9 - return (f&mask != 0) -} - -// Set9 will set the flag bit value at index 9. -func (f Flags32) Set9() Flags32 { - const mask = Flags32(1) << 9 - return f | mask -} - -// Unset9 will unset the flag bit value at index 9. -func (f Flags32) Unset9() Flags32 { - const mask = Flags32(1) << 9 - return f & ^mask -} - -// Get10 will fetch the flag bit value at index 10. -func (f Flags32) Get10() bool { - const mask = Flags32(1) << 10 - return (f&mask != 0) -} - -// Set10 will set the flag bit value at index 10. -func (f Flags32) Set10() Flags32 { - const mask = Flags32(1) << 10 - return f | mask -} - -// Unset10 will unset the flag bit value at index 10. -func (f Flags32) Unset10() Flags32 { - const mask = Flags32(1) << 10 - return f & ^mask -} - -// Get11 will fetch the flag bit value at index 11. -func (f Flags32) Get11() bool { - const mask = Flags32(1) << 11 - return (f&mask != 0) -} - -// Set11 will set the flag bit value at index 11. -func (f Flags32) Set11() Flags32 { - const mask = Flags32(1) << 11 - return f | mask -} - -// Unset11 will unset the flag bit value at index 11. -func (f Flags32) Unset11() Flags32 { - const mask = Flags32(1) << 11 - return f & ^mask -} - -// Get12 will fetch the flag bit value at index 12. -func (f Flags32) Get12() bool { - const mask = Flags32(1) << 12 - return (f&mask != 0) -} - -// Set12 will set the flag bit value at index 12. -func (f Flags32) Set12() Flags32 { - const mask = Flags32(1) << 12 - return f | mask -} - -// Unset12 will unset the flag bit value at index 12. -func (f Flags32) Unset12() Flags32 { - const mask = Flags32(1) << 12 - return f & ^mask -} - -// Get13 will fetch the flag bit value at index 13. -func (f Flags32) Get13() bool { - const mask = Flags32(1) << 13 - return (f&mask != 0) -} - -// Set13 will set the flag bit value at index 13. -func (f Flags32) Set13() Flags32 { - const mask = Flags32(1) << 13 - return f | mask -} - -// Unset13 will unset the flag bit value at index 13. -func (f Flags32) Unset13() Flags32 { - const mask = Flags32(1) << 13 - return f & ^mask -} - -// Get14 will fetch the flag bit value at index 14. -func (f Flags32) Get14() bool { - const mask = Flags32(1) << 14 - return (f&mask != 0) -} - -// Set14 will set the flag bit value at index 14. -func (f Flags32) Set14() Flags32 { - const mask = Flags32(1) << 14 - return f | mask -} - -// Unset14 will unset the flag bit value at index 14. -func (f Flags32) Unset14() Flags32 { - const mask = Flags32(1) << 14 - return f & ^mask -} - -// Get15 will fetch the flag bit value at index 15. -func (f Flags32) Get15() bool { - const mask = Flags32(1) << 15 - return (f&mask != 0) -} - -// Set15 will set the flag bit value at index 15. -func (f Flags32) Set15() Flags32 { - const mask = Flags32(1) << 15 - return f | mask -} - -// Unset15 will unset the flag bit value at index 15. -func (f Flags32) Unset15() Flags32 { - const mask = Flags32(1) << 15 - return f & ^mask -} - -// Get16 will fetch the flag bit value at index 16. -func (f Flags32) Get16() bool { - const mask = Flags32(1) << 16 - return (f&mask != 0) -} - -// Set16 will set the flag bit value at index 16. -func (f Flags32) Set16() Flags32 { - const mask = Flags32(1) << 16 - return f | mask -} - -// Unset16 will unset the flag bit value at index 16. -func (f Flags32) Unset16() Flags32 { - const mask = Flags32(1) << 16 - return f & ^mask -} - -// Get17 will fetch the flag bit value at index 17. -func (f Flags32) Get17() bool { - const mask = Flags32(1) << 17 - return (f&mask != 0) -} - -// Set17 will set the flag bit value at index 17. -func (f Flags32) Set17() Flags32 { - const mask = Flags32(1) << 17 - return f | mask -} - -// Unset17 will unset the flag bit value at index 17. -func (f Flags32) Unset17() Flags32 { - const mask = Flags32(1) << 17 - return f & ^mask -} - -// Get18 will fetch the flag bit value at index 18. -func (f Flags32) Get18() bool { - const mask = Flags32(1) << 18 - return (f&mask != 0) -} - -// Set18 will set the flag bit value at index 18. -func (f Flags32) Set18() Flags32 { - const mask = Flags32(1) << 18 - return f | mask -} - -// Unset18 will unset the flag bit value at index 18. -func (f Flags32) Unset18() Flags32 { - const mask = Flags32(1) << 18 - return f & ^mask -} - -// Get19 will fetch the flag bit value at index 19. -func (f Flags32) Get19() bool { - const mask = Flags32(1) << 19 - return (f&mask != 0) -} - -// Set19 will set the flag bit value at index 19. -func (f Flags32) Set19() Flags32 { - const mask = Flags32(1) << 19 - return f | mask -} - -// Unset19 will unset the flag bit value at index 19. -func (f Flags32) Unset19() Flags32 { - const mask = Flags32(1) << 19 - return f & ^mask -} - -// Get20 will fetch the flag bit value at index 20. -func (f Flags32) Get20() bool { - const mask = Flags32(1) << 20 - return (f&mask != 0) -} - -// Set20 will set the flag bit value at index 20. -func (f Flags32) Set20() Flags32 { - const mask = Flags32(1) << 20 - return f | mask -} - -// Unset20 will unset the flag bit value at index 20. -func (f Flags32) Unset20() Flags32 { - const mask = Flags32(1) << 20 - return f & ^mask -} - -// Get21 will fetch the flag bit value at index 21. -func (f Flags32) Get21() bool { - const mask = Flags32(1) << 21 - return (f&mask != 0) -} - -// Set21 will set the flag bit value at index 21. -func (f Flags32) Set21() Flags32 { - const mask = Flags32(1) << 21 - return f | mask -} - -// Unset21 will unset the flag bit value at index 21. -func (f Flags32) Unset21() Flags32 { - const mask = Flags32(1) << 21 - return f & ^mask -} - -// Get22 will fetch the flag bit value at index 22. -func (f Flags32) Get22() bool { - const mask = Flags32(1) << 22 - return (f&mask != 0) -} - -// Set22 will set the flag bit value at index 22. -func (f Flags32) Set22() Flags32 { - const mask = Flags32(1) << 22 - return f | mask -} - -// Unset22 will unset the flag bit value at index 22. -func (f Flags32) Unset22() Flags32 { - const mask = Flags32(1) << 22 - return f & ^mask -} - -// Get23 will fetch the flag bit value at index 23. -func (f Flags32) Get23() bool { - const mask = Flags32(1) << 23 - return (f&mask != 0) -} - -// Set23 will set the flag bit value at index 23. -func (f Flags32) Set23() Flags32 { - const mask = Flags32(1) << 23 - return f | mask -} - -// Unset23 will unset the flag bit value at index 23. -func (f Flags32) Unset23() Flags32 { - const mask = Flags32(1) << 23 - return f & ^mask -} - -// Get24 will fetch the flag bit value at index 24. -func (f Flags32) Get24() bool { - const mask = Flags32(1) << 24 - return (f&mask != 0) -} - -// Set24 will set the flag bit value at index 24. -func (f Flags32) Set24() Flags32 { - const mask = Flags32(1) << 24 - return f | mask -} - -// Unset24 will unset the flag bit value at index 24. -func (f Flags32) Unset24() Flags32 { - const mask = Flags32(1) << 24 - return f & ^mask -} - -// Get25 will fetch the flag bit value at index 25. -func (f Flags32) Get25() bool { - const mask = Flags32(1) << 25 - return (f&mask != 0) -} - -// Set25 will set the flag bit value at index 25. -func (f Flags32) Set25() Flags32 { - const mask = Flags32(1) << 25 - return f | mask -} - -// Unset25 will unset the flag bit value at index 25. -func (f Flags32) Unset25() Flags32 { - const mask = Flags32(1) << 25 - return f & ^mask -} - -// Get26 will fetch the flag bit value at index 26. -func (f Flags32) Get26() bool { - const mask = Flags32(1) << 26 - return (f&mask != 0) -} - -// Set26 will set the flag bit value at index 26. -func (f Flags32) Set26() Flags32 { - const mask = Flags32(1) << 26 - return f | mask -} - -// Unset26 will unset the flag bit value at index 26. -func (f Flags32) Unset26() Flags32 { - const mask = Flags32(1) << 26 - return f & ^mask -} - -// Get27 will fetch the flag bit value at index 27. -func (f Flags32) Get27() bool { - const mask = Flags32(1) << 27 - return (f&mask != 0) -} - -// Set27 will set the flag bit value at index 27. -func (f Flags32) Set27() Flags32 { - const mask = Flags32(1) << 27 - return f | mask -} - -// Unset27 will unset the flag bit value at index 27. -func (f Flags32) Unset27() Flags32 { - const mask = Flags32(1) << 27 - return f & ^mask -} - -// Get28 will fetch the flag bit value at index 28. -func (f Flags32) Get28() bool { - const mask = Flags32(1) << 28 - return (f&mask != 0) -} - -// Set28 will set the flag bit value at index 28. -func (f Flags32) Set28() Flags32 { - const mask = Flags32(1) << 28 - return f | mask -} - -// Unset28 will unset the flag bit value at index 28. -func (f Flags32) Unset28() Flags32 { - const mask = Flags32(1) << 28 - return f & ^mask -} - -// Get29 will fetch the flag bit value at index 29. -func (f Flags32) Get29() bool { - const mask = Flags32(1) << 29 - return (f&mask != 0) -} - -// Set29 will set the flag bit value at index 29. -func (f Flags32) Set29() Flags32 { - const mask = Flags32(1) << 29 - return f | mask -} - -// Unset29 will unset the flag bit value at index 29. -func (f Flags32) Unset29() Flags32 { - const mask = Flags32(1) << 29 - return f & ^mask -} - -// Get30 will fetch the flag bit value at index 30. -func (f Flags32) Get30() bool { - const mask = Flags32(1) << 30 - return (f&mask != 0) -} - -// Set30 will set the flag bit value at index 30. -func (f Flags32) Set30() Flags32 { - const mask = Flags32(1) << 30 - return f | mask -} - -// Unset30 will unset the flag bit value at index 30. -func (f Flags32) Unset30() Flags32 { - const mask = Flags32(1) << 30 - return f & ^mask -} - -// Get31 will fetch the flag bit value at index 31. -func (f Flags32) Get31() bool { - const mask = Flags32(1) << 31 - return (f&mask != 0) -} - -// Set31 will set the flag bit value at index 31. -func (f Flags32) Set31() Flags32 { - const mask = Flags32(1) << 31 - return f | mask -} - -// Unset31 will unset the flag bit value at index 31. -func (f Flags32) Unset31() Flags32 { - const mask = Flags32(1) << 31 - return f & ^mask -} - -// String returns a human readable representation of Flags32. -func (f Flags32) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 32) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags32. -func (f Flags32) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags32{") + (len("31=false ") * 32) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags32{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], "8=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], "9=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], "10=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], "11=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], "12=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], "13=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], "14=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], "15=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], "16=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], "17=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], "18=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], "19=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], "20=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], "21=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], "22=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], "23=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], "24=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], "25=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], "26=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], "27=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], "28=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], "29=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], "30=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], "31=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// Flags64 is a type-casted unsigned integer with helper -// methods for easily managing up to 64 bit-flags. -type Flags64 uint64 - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags64) Get(bit uint8) bool { - mask := Flags64(1) << bit - return (f&mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags64) Set(bit uint8) Flags64 { - mask := Flags64(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags64) Unset(bit uint8) Flags64 { - mask := Flags64(1) << bit - return f & ^mask -} - -// Get0 will fetch the flag bit value at index 0. -func (f Flags64) Get0() bool { - const mask = Flags64(1) << 0 - return (f&mask != 0) -} - -// Set0 will set the flag bit value at index 0. -func (f Flags64) Set0() Flags64 { - const mask = Flags64(1) << 0 - return f | mask -} - -// Unset0 will unset the flag bit value at index 0. -func (f Flags64) Unset0() Flags64 { - const mask = Flags64(1) << 0 - return f & ^mask -} - -// Get1 will fetch the flag bit value at index 1. -func (f Flags64) Get1() bool { - const mask = Flags64(1) << 1 - return (f&mask != 0) -} - -// Set1 will set the flag bit value at index 1. -func (f Flags64) Set1() Flags64 { - const mask = Flags64(1) << 1 - return f | mask -} - -// Unset1 will unset the flag bit value at index 1. -func (f Flags64) Unset1() Flags64 { - const mask = Flags64(1) << 1 - return f & ^mask -} - -// Get2 will fetch the flag bit value at index 2. -func (f Flags64) Get2() bool { - const mask = Flags64(1) << 2 - return (f&mask != 0) -} - -// Set2 will set the flag bit value at index 2. -func (f Flags64) Set2() Flags64 { - const mask = Flags64(1) << 2 - return f | mask -} - -// Unset2 will unset the flag bit value at index 2. -func (f Flags64) Unset2() Flags64 { - const mask = Flags64(1) << 2 - return f & ^mask -} - -// Get3 will fetch the flag bit value at index 3. -func (f Flags64) Get3() bool { - const mask = Flags64(1) << 3 - return (f&mask != 0) -} - -// Set3 will set the flag bit value at index 3. -func (f Flags64) Set3() Flags64 { - const mask = Flags64(1) << 3 - return f | mask -} - -// Unset3 will unset the flag bit value at index 3. -func (f Flags64) Unset3() Flags64 { - const mask = Flags64(1) << 3 - return f & ^mask -} - -// Get4 will fetch the flag bit value at index 4. -func (f Flags64) Get4() bool { - const mask = Flags64(1) << 4 - return (f&mask != 0) -} - -// Set4 will set the flag bit value at index 4. -func (f Flags64) Set4() Flags64 { - const mask = Flags64(1) << 4 - return f | mask -} - -// Unset4 will unset the flag bit value at index 4. -func (f Flags64) Unset4() Flags64 { - const mask = Flags64(1) << 4 - return f & ^mask -} - -// Get5 will fetch the flag bit value at index 5. -func (f Flags64) Get5() bool { - const mask = Flags64(1) << 5 - return (f&mask != 0) -} - -// Set5 will set the flag bit value at index 5. -func (f Flags64) Set5() Flags64 { - const mask = Flags64(1) << 5 - return f | mask -} - -// Unset5 will unset the flag bit value at index 5. -func (f Flags64) Unset5() Flags64 { - const mask = Flags64(1) << 5 - return f & ^mask -} - -// Get6 will fetch the flag bit value at index 6. -func (f Flags64) Get6() bool { - const mask = Flags64(1) << 6 - return (f&mask != 0) -} - -// Set6 will set the flag bit value at index 6. -func (f Flags64) Set6() Flags64 { - const mask = Flags64(1) << 6 - return f | mask -} - -// Unset6 will unset the flag bit value at index 6. -func (f Flags64) Unset6() Flags64 { - const mask = Flags64(1) << 6 - return f & ^mask -} - -// Get7 will fetch the flag bit value at index 7. -func (f Flags64) Get7() bool { - const mask = Flags64(1) << 7 - return (f&mask != 0) -} - -// Set7 will set the flag bit value at index 7. -func (f Flags64) Set7() Flags64 { - const mask = Flags64(1) << 7 - return f | mask -} - -// Unset7 will unset the flag bit value at index 7. -func (f Flags64) Unset7() Flags64 { - const mask = Flags64(1) << 7 - return f & ^mask -} - -// Get8 will fetch the flag bit value at index 8. -func (f Flags64) Get8() bool { - const mask = Flags64(1) << 8 - return (f&mask != 0) -} - -// Set8 will set the flag bit value at index 8. -func (f Flags64) Set8() Flags64 { - const mask = Flags64(1) << 8 - return f | mask -} - -// Unset8 will unset the flag bit value at index 8. -func (f Flags64) Unset8() Flags64 { - const mask = Flags64(1) << 8 - return f & ^mask -} - -// Get9 will fetch the flag bit value at index 9. -func (f Flags64) Get9() bool { - const mask = Flags64(1) << 9 - return (f&mask != 0) -} - -// Set9 will set the flag bit value at index 9. -func (f Flags64) Set9() Flags64 { - const mask = Flags64(1) << 9 - return f | mask -} - -// Unset9 will unset the flag bit value at index 9. -func (f Flags64) Unset9() Flags64 { - const mask = Flags64(1) << 9 - return f & ^mask -} - -// Get10 will fetch the flag bit value at index 10. -func (f Flags64) Get10() bool { - const mask = Flags64(1) << 10 - return (f&mask != 0) -} - -// Set10 will set the flag bit value at index 10. -func (f Flags64) Set10() Flags64 { - const mask = Flags64(1) << 10 - return f | mask -} - -// Unset10 will unset the flag bit value at index 10. -func (f Flags64) Unset10() Flags64 { - const mask = Flags64(1) << 10 - return f & ^mask -} - -// Get11 will fetch the flag bit value at index 11. -func (f Flags64) Get11() bool { - const mask = Flags64(1) << 11 - return (f&mask != 0) -} - -// Set11 will set the flag bit value at index 11. -func (f Flags64) Set11() Flags64 { - const mask = Flags64(1) << 11 - return f | mask -} - -// Unset11 will unset the flag bit value at index 11. -func (f Flags64) Unset11() Flags64 { - const mask = Flags64(1) << 11 - return f & ^mask -} - -// Get12 will fetch the flag bit value at index 12. -func (f Flags64) Get12() bool { - const mask = Flags64(1) << 12 - return (f&mask != 0) -} - -// Set12 will set the flag bit value at index 12. -func (f Flags64) Set12() Flags64 { - const mask = Flags64(1) << 12 - return f | mask -} - -// Unset12 will unset the flag bit value at index 12. -func (f Flags64) Unset12() Flags64 { - const mask = Flags64(1) << 12 - return f & ^mask -} - -// Get13 will fetch the flag bit value at index 13. -func (f Flags64) Get13() bool { - const mask = Flags64(1) << 13 - return (f&mask != 0) -} - -// Set13 will set the flag bit value at index 13. -func (f Flags64) Set13() Flags64 { - const mask = Flags64(1) << 13 - return f | mask -} - -// Unset13 will unset the flag bit value at index 13. -func (f Flags64) Unset13() Flags64 { - const mask = Flags64(1) << 13 - return f & ^mask -} - -// Get14 will fetch the flag bit value at index 14. -func (f Flags64) Get14() bool { - const mask = Flags64(1) << 14 - return (f&mask != 0) -} - -// Set14 will set the flag bit value at index 14. -func (f Flags64) Set14() Flags64 { - const mask = Flags64(1) << 14 - return f | mask -} - -// Unset14 will unset the flag bit value at index 14. -func (f Flags64) Unset14() Flags64 { - const mask = Flags64(1) << 14 - return f & ^mask -} - -// Get15 will fetch the flag bit value at index 15. -func (f Flags64) Get15() bool { - const mask = Flags64(1) << 15 - return (f&mask != 0) -} - -// Set15 will set the flag bit value at index 15. -func (f Flags64) Set15() Flags64 { - const mask = Flags64(1) << 15 - return f | mask -} - -// Unset15 will unset the flag bit value at index 15. -func (f Flags64) Unset15() Flags64 { - const mask = Flags64(1) << 15 - return f & ^mask -} - -// Get16 will fetch the flag bit value at index 16. -func (f Flags64) Get16() bool { - const mask = Flags64(1) << 16 - return (f&mask != 0) -} - -// Set16 will set the flag bit value at index 16. -func (f Flags64) Set16() Flags64 { - const mask = Flags64(1) << 16 - return f | mask -} - -// Unset16 will unset the flag bit value at index 16. -func (f Flags64) Unset16() Flags64 { - const mask = Flags64(1) << 16 - return f & ^mask -} - -// Get17 will fetch the flag bit value at index 17. -func (f Flags64) Get17() bool { - const mask = Flags64(1) << 17 - return (f&mask != 0) -} - -// Set17 will set the flag bit value at index 17. -func (f Flags64) Set17() Flags64 { - const mask = Flags64(1) << 17 - return f | mask -} - -// Unset17 will unset the flag bit value at index 17. -func (f Flags64) Unset17() Flags64 { - const mask = Flags64(1) << 17 - return f & ^mask -} - -// Get18 will fetch the flag bit value at index 18. -func (f Flags64) Get18() bool { - const mask = Flags64(1) << 18 - return (f&mask != 0) -} - -// Set18 will set the flag bit value at index 18. -func (f Flags64) Set18() Flags64 { - const mask = Flags64(1) << 18 - return f | mask -} - -// Unset18 will unset the flag bit value at index 18. -func (f Flags64) Unset18() Flags64 { - const mask = Flags64(1) << 18 - return f & ^mask -} - -// Get19 will fetch the flag bit value at index 19. -func (f Flags64) Get19() bool { - const mask = Flags64(1) << 19 - return (f&mask != 0) -} - -// Set19 will set the flag bit value at index 19. -func (f Flags64) Set19() Flags64 { - const mask = Flags64(1) << 19 - return f | mask -} - -// Unset19 will unset the flag bit value at index 19. -func (f Flags64) Unset19() Flags64 { - const mask = Flags64(1) << 19 - return f & ^mask -} - -// Get20 will fetch the flag bit value at index 20. -func (f Flags64) Get20() bool { - const mask = Flags64(1) << 20 - return (f&mask != 0) -} - -// Set20 will set the flag bit value at index 20. -func (f Flags64) Set20() Flags64 { - const mask = Flags64(1) << 20 - return f | mask -} - -// Unset20 will unset the flag bit value at index 20. -func (f Flags64) Unset20() Flags64 { - const mask = Flags64(1) << 20 - return f & ^mask -} - -// Get21 will fetch the flag bit value at index 21. -func (f Flags64) Get21() bool { - const mask = Flags64(1) << 21 - return (f&mask != 0) -} - -// Set21 will set the flag bit value at index 21. -func (f Flags64) Set21() Flags64 { - const mask = Flags64(1) << 21 - return f | mask -} - -// Unset21 will unset the flag bit value at index 21. -func (f Flags64) Unset21() Flags64 { - const mask = Flags64(1) << 21 - return f & ^mask -} - -// Get22 will fetch the flag bit value at index 22. -func (f Flags64) Get22() bool { - const mask = Flags64(1) << 22 - return (f&mask != 0) -} - -// Set22 will set the flag bit value at index 22. -func (f Flags64) Set22() Flags64 { - const mask = Flags64(1) << 22 - return f | mask -} - -// Unset22 will unset the flag bit value at index 22. -func (f Flags64) Unset22() Flags64 { - const mask = Flags64(1) << 22 - return f & ^mask -} - -// Get23 will fetch the flag bit value at index 23. -func (f Flags64) Get23() bool { - const mask = Flags64(1) << 23 - return (f&mask != 0) -} - -// Set23 will set the flag bit value at index 23. -func (f Flags64) Set23() Flags64 { - const mask = Flags64(1) << 23 - return f | mask -} - -// Unset23 will unset the flag bit value at index 23. -func (f Flags64) Unset23() Flags64 { - const mask = Flags64(1) << 23 - return f & ^mask -} - -// Get24 will fetch the flag bit value at index 24. -func (f Flags64) Get24() bool { - const mask = Flags64(1) << 24 - return (f&mask != 0) -} - -// Set24 will set the flag bit value at index 24. -func (f Flags64) Set24() Flags64 { - const mask = Flags64(1) << 24 - return f | mask -} - -// Unset24 will unset the flag bit value at index 24. -func (f Flags64) Unset24() Flags64 { - const mask = Flags64(1) << 24 - return f & ^mask -} - -// Get25 will fetch the flag bit value at index 25. -func (f Flags64) Get25() bool { - const mask = Flags64(1) << 25 - return (f&mask != 0) -} - -// Set25 will set the flag bit value at index 25. -func (f Flags64) Set25() Flags64 { - const mask = Flags64(1) << 25 - return f | mask -} - -// Unset25 will unset the flag bit value at index 25. -func (f Flags64) Unset25() Flags64 { - const mask = Flags64(1) << 25 - return f & ^mask -} - -// Get26 will fetch the flag bit value at index 26. -func (f Flags64) Get26() bool { - const mask = Flags64(1) << 26 - return (f&mask != 0) -} - -// Set26 will set the flag bit value at index 26. -func (f Flags64) Set26() Flags64 { - const mask = Flags64(1) << 26 - return f | mask -} - -// Unset26 will unset the flag bit value at index 26. -func (f Flags64) Unset26() Flags64 { - const mask = Flags64(1) << 26 - return f & ^mask -} - -// Get27 will fetch the flag bit value at index 27. -func (f Flags64) Get27() bool { - const mask = Flags64(1) << 27 - return (f&mask != 0) -} - -// Set27 will set the flag bit value at index 27. -func (f Flags64) Set27() Flags64 { - const mask = Flags64(1) << 27 - return f | mask -} - -// Unset27 will unset the flag bit value at index 27. -func (f Flags64) Unset27() Flags64 { - const mask = Flags64(1) << 27 - return f & ^mask -} - -// Get28 will fetch the flag bit value at index 28. -func (f Flags64) Get28() bool { - const mask = Flags64(1) << 28 - return (f&mask != 0) -} - -// Set28 will set the flag bit value at index 28. -func (f Flags64) Set28() Flags64 { - const mask = Flags64(1) << 28 - return f | mask -} - -// Unset28 will unset the flag bit value at index 28. -func (f Flags64) Unset28() Flags64 { - const mask = Flags64(1) << 28 - return f & ^mask -} - -// Get29 will fetch the flag bit value at index 29. -func (f Flags64) Get29() bool { - const mask = Flags64(1) << 29 - return (f&mask != 0) -} - -// Set29 will set the flag bit value at index 29. -func (f Flags64) Set29() Flags64 { - const mask = Flags64(1) << 29 - return f | mask -} - -// Unset29 will unset the flag bit value at index 29. -func (f Flags64) Unset29() Flags64 { - const mask = Flags64(1) << 29 - return f & ^mask -} - -// Get30 will fetch the flag bit value at index 30. -func (f Flags64) Get30() bool { - const mask = Flags64(1) << 30 - return (f&mask != 0) -} - -// Set30 will set the flag bit value at index 30. -func (f Flags64) Set30() Flags64 { - const mask = Flags64(1) << 30 - return f | mask -} - -// Unset30 will unset the flag bit value at index 30. -func (f Flags64) Unset30() Flags64 { - const mask = Flags64(1) << 30 - return f & ^mask -} - -// Get31 will fetch the flag bit value at index 31. -func (f Flags64) Get31() bool { - const mask = Flags64(1) << 31 - return (f&mask != 0) -} - -// Set31 will set the flag bit value at index 31. -func (f Flags64) Set31() Flags64 { - const mask = Flags64(1) << 31 - return f | mask -} - -// Unset31 will unset the flag bit value at index 31. -func (f Flags64) Unset31() Flags64 { - const mask = Flags64(1) << 31 - return f & ^mask -} - -// Get32 will fetch the flag bit value at index 32. -func (f Flags64) Get32() bool { - const mask = Flags64(1) << 32 - return (f&mask != 0) -} - -// Set32 will set the flag bit value at index 32. -func (f Flags64) Set32() Flags64 { - const mask = Flags64(1) << 32 - return f | mask -} - -// Unset32 will unset the flag bit value at index 32. -func (f Flags64) Unset32() Flags64 { - const mask = Flags64(1) << 32 - return f & ^mask -} - -// Get33 will fetch the flag bit value at index 33. -func (f Flags64) Get33() bool { - const mask = Flags64(1) << 33 - return (f&mask != 0) -} - -// Set33 will set the flag bit value at index 33. -func (f Flags64) Set33() Flags64 { - const mask = Flags64(1) << 33 - return f | mask -} - -// Unset33 will unset the flag bit value at index 33. -func (f Flags64) Unset33() Flags64 { - const mask = Flags64(1) << 33 - return f & ^mask -} - -// Get34 will fetch the flag bit value at index 34. -func (f Flags64) Get34() bool { - const mask = Flags64(1) << 34 - return (f&mask != 0) -} - -// Set34 will set the flag bit value at index 34. -func (f Flags64) Set34() Flags64 { - const mask = Flags64(1) << 34 - return f | mask -} - -// Unset34 will unset the flag bit value at index 34. -func (f Flags64) Unset34() Flags64 { - const mask = Flags64(1) << 34 - return f & ^mask -} - -// Get35 will fetch the flag bit value at index 35. -func (f Flags64) Get35() bool { - const mask = Flags64(1) << 35 - return (f&mask != 0) -} - -// Set35 will set the flag bit value at index 35. -func (f Flags64) Set35() Flags64 { - const mask = Flags64(1) << 35 - return f | mask -} - -// Unset35 will unset the flag bit value at index 35. -func (f Flags64) Unset35() Flags64 { - const mask = Flags64(1) << 35 - return f & ^mask -} - -// Get36 will fetch the flag bit value at index 36. -func (f Flags64) Get36() bool { - const mask = Flags64(1) << 36 - return (f&mask != 0) -} - -// Set36 will set the flag bit value at index 36. -func (f Flags64) Set36() Flags64 { - const mask = Flags64(1) << 36 - return f | mask -} - -// Unset36 will unset the flag bit value at index 36. -func (f Flags64) Unset36() Flags64 { - const mask = Flags64(1) << 36 - return f & ^mask -} - -// Get37 will fetch the flag bit value at index 37. -func (f Flags64) Get37() bool { - const mask = Flags64(1) << 37 - return (f&mask != 0) -} - -// Set37 will set the flag bit value at index 37. -func (f Flags64) Set37() Flags64 { - const mask = Flags64(1) << 37 - return f | mask -} - -// Unset37 will unset the flag bit value at index 37. -func (f Flags64) Unset37() Flags64 { - const mask = Flags64(1) << 37 - return f & ^mask -} - -// Get38 will fetch the flag bit value at index 38. -func (f Flags64) Get38() bool { - const mask = Flags64(1) << 38 - return (f&mask != 0) -} - -// Set38 will set the flag bit value at index 38. -func (f Flags64) Set38() Flags64 { - const mask = Flags64(1) << 38 - return f | mask -} - -// Unset38 will unset the flag bit value at index 38. -func (f Flags64) Unset38() Flags64 { - const mask = Flags64(1) << 38 - return f & ^mask -} - -// Get39 will fetch the flag bit value at index 39. -func (f Flags64) Get39() bool { - const mask = Flags64(1) << 39 - return (f&mask != 0) -} - -// Set39 will set the flag bit value at index 39. -func (f Flags64) Set39() Flags64 { - const mask = Flags64(1) << 39 - return f | mask -} - -// Unset39 will unset the flag bit value at index 39. -func (f Flags64) Unset39() Flags64 { - const mask = Flags64(1) << 39 - return f & ^mask -} - -// Get40 will fetch the flag bit value at index 40. -func (f Flags64) Get40() bool { - const mask = Flags64(1) << 40 - return (f&mask != 0) -} - -// Set40 will set the flag bit value at index 40. -func (f Flags64) Set40() Flags64 { - const mask = Flags64(1) << 40 - return f | mask -} - -// Unset40 will unset the flag bit value at index 40. -func (f Flags64) Unset40() Flags64 { - const mask = Flags64(1) << 40 - return f & ^mask -} - -// Get41 will fetch the flag bit value at index 41. -func (f Flags64) Get41() bool { - const mask = Flags64(1) << 41 - return (f&mask != 0) -} - -// Set41 will set the flag bit value at index 41. -func (f Flags64) Set41() Flags64 { - const mask = Flags64(1) << 41 - return f | mask -} - -// Unset41 will unset the flag bit value at index 41. -func (f Flags64) Unset41() Flags64 { - const mask = Flags64(1) << 41 - return f & ^mask -} - -// Get42 will fetch the flag bit value at index 42. -func (f Flags64) Get42() bool { - const mask = Flags64(1) << 42 - return (f&mask != 0) -} - -// Set42 will set the flag bit value at index 42. -func (f Flags64) Set42() Flags64 { - const mask = Flags64(1) << 42 - return f | mask -} - -// Unset42 will unset the flag bit value at index 42. -func (f Flags64) Unset42() Flags64 { - const mask = Flags64(1) << 42 - return f & ^mask -} - -// Get43 will fetch the flag bit value at index 43. -func (f Flags64) Get43() bool { - const mask = Flags64(1) << 43 - return (f&mask != 0) -} - -// Set43 will set the flag bit value at index 43. -func (f Flags64) Set43() Flags64 { - const mask = Flags64(1) << 43 - return f | mask -} - -// Unset43 will unset the flag bit value at index 43. -func (f Flags64) Unset43() Flags64 { - const mask = Flags64(1) << 43 - return f & ^mask -} - -// Get44 will fetch the flag bit value at index 44. -func (f Flags64) Get44() bool { - const mask = Flags64(1) << 44 - return (f&mask != 0) -} - -// Set44 will set the flag bit value at index 44. -func (f Flags64) Set44() Flags64 { - const mask = Flags64(1) << 44 - return f | mask -} - -// Unset44 will unset the flag bit value at index 44. -func (f Flags64) Unset44() Flags64 { - const mask = Flags64(1) << 44 - return f & ^mask -} - -// Get45 will fetch the flag bit value at index 45. -func (f Flags64) Get45() bool { - const mask = Flags64(1) << 45 - return (f&mask != 0) -} - -// Set45 will set the flag bit value at index 45. -func (f Flags64) Set45() Flags64 { - const mask = Flags64(1) << 45 - return f | mask -} - -// Unset45 will unset the flag bit value at index 45. -func (f Flags64) Unset45() Flags64 { - const mask = Flags64(1) << 45 - return f & ^mask -} - -// Get46 will fetch the flag bit value at index 46. -func (f Flags64) Get46() bool { - const mask = Flags64(1) << 46 - return (f&mask != 0) -} - -// Set46 will set the flag bit value at index 46. -func (f Flags64) Set46() Flags64 { - const mask = Flags64(1) << 46 - return f | mask -} - -// Unset46 will unset the flag bit value at index 46. -func (f Flags64) Unset46() Flags64 { - const mask = Flags64(1) << 46 - return f & ^mask -} - -// Get47 will fetch the flag bit value at index 47. -func (f Flags64) Get47() bool { - const mask = Flags64(1) << 47 - return (f&mask != 0) -} - -// Set47 will set the flag bit value at index 47. -func (f Flags64) Set47() Flags64 { - const mask = Flags64(1) << 47 - return f | mask -} - -// Unset47 will unset the flag bit value at index 47. -func (f Flags64) Unset47() Flags64 { - const mask = Flags64(1) << 47 - return f & ^mask -} - -// Get48 will fetch the flag bit value at index 48. -func (f Flags64) Get48() bool { - const mask = Flags64(1) << 48 - return (f&mask != 0) -} - -// Set48 will set the flag bit value at index 48. -func (f Flags64) Set48() Flags64 { - const mask = Flags64(1) << 48 - return f | mask -} - -// Unset48 will unset the flag bit value at index 48. -func (f Flags64) Unset48() Flags64 { - const mask = Flags64(1) << 48 - return f & ^mask -} - -// Get49 will fetch the flag bit value at index 49. -func (f Flags64) Get49() bool { - const mask = Flags64(1) << 49 - return (f&mask != 0) -} - -// Set49 will set the flag bit value at index 49. -func (f Flags64) Set49() Flags64 { - const mask = Flags64(1) << 49 - return f | mask -} - -// Unset49 will unset the flag bit value at index 49. -func (f Flags64) Unset49() Flags64 { - const mask = Flags64(1) << 49 - return f & ^mask -} - -// Get50 will fetch the flag bit value at index 50. -func (f Flags64) Get50() bool { - const mask = Flags64(1) << 50 - return (f&mask != 0) -} - -// Set50 will set the flag bit value at index 50. -func (f Flags64) Set50() Flags64 { - const mask = Flags64(1) << 50 - return f | mask -} - -// Unset50 will unset the flag bit value at index 50. -func (f Flags64) Unset50() Flags64 { - const mask = Flags64(1) << 50 - return f & ^mask -} - -// Get51 will fetch the flag bit value at index 51. -func (f Flags64) Get51() bool { - const mask = Flags64(1) << 51 - return (f&mask != 0) -} - -// Set51 will set the flag bit value at index 51. -func (f Flags64) Set51() Flags64 { - const mask = Flags64(1) << 51 - return f | mask -} - -// Unset51 will unset the flag bit value at index 51. -func (f Flags64) Unset51() Flags64 { - const mask = Flags64(1) << 51 - return f & ^mask -} - -// Get52 will fetch the flag bit value at index 52. -func (f Flags64) Get52() bool { - const mask = Flags64(1) << 52 - return (f&mask != 0) -} - -// Set52 will set the flag bit value at index 52. -func (f Flags64) Set52() Flags64 { - const mask = Flags64(1) << 52 - return f | mask -} - -// Unset52 will unset the flag bit value at index 52. -func (f Flags64) Unset52() Flags64 { - const mask = Flags64(1) << 52 - return f & ^mask -} - -// Get53 will fetch the flag bit value at index 53. -func (f Flags64) Get53() bool { - const mask = Flags64(1) << 53 - return (f&mask != 0) -} - -// Set53 will set the flag bit value at index 53. -func (f Flags64) Set53() Flags64 { - const mask = Flags64(1) << 53 - return f | mask -} - -// Unset53 will unset the flag bit value at index 53. -func (f Flags64) Unset53() Flags64 { - const mask = Flags64(1) << 53 - return f & ^mask -} - -// Get54 will fetch the flag bit value at index 54. -func (f Flags64) Get54() bool { - const mask = Flags64(1) << 54 - return (f&mask != 0) -} - -// Set54 will set the flag bit value at index 54. -func (f Flags64) Set54() Flags64 { - const mask = Flags64(1) << 54 - return f | mask -} - -// Unset54 will unset the flag bit value at index 54. -func (f Flags64) Unset54() Flags64 { - const mask = Flags64(1) << 54 - return f & ^mask -} - -// Get55 will fetch the flag bit value at index 55. -func (f Flags64) Get55() bool { - const mask = Flags64(1) << 55 - return (f&mask != 0) -} - -// Set55 will set the flag bit value at index 55. -func (f Flags64) Set55() Flags64 { - const mask = Flags64(1) << 55 - return f | mask -} - -// Unset55 will unset the flag bit value at index 55. -func (f Flags64) Unset55() Flags64 { - const mask = Flags64(1) << 55 - return f & ^mask -} - -// Get56 will fetch the flag bit value at index 56. -func (f Flags64) Get56() bool { - const mask = Flags64(1) << 56 - return (f&mask != 0) -} - -// Set56 will set the flag bit value at index 56. -func (f Flags64) Set56() Flags64 { - const mask = Flags64(1) << 56 - return f | mask -} - -// Unset56 will unset the flag bit value at index 56. -func (f Flags64) Unset56() Flags64 { - const mask = Flags64(1) << 56 - return f & ^mask -} - -// Get57 will fetch the flag bit value at index 57. -func (f Flags64) Get57() bool { - const mask = Flags64(1) << 57 - return (f&mask != 0) -} - -// Set57 will set the flag bit value at index 57. -func (f Flags64) Set57() Flags64 { - const mask = Flags64(1) << 57 - return f | mask -} - -// Unset57 will unset the flag bit value at index 57. -func (f Flags64) Unset57() Flags64 { - const mask = Flags64(1) << 57 - return f & ^mask -} - -// Get58 will fetch the flag bit value at index 58. -func (f Flags64) Get58() bool { - const mask = Flags64(1) << 58 - return (f&mask != 0) -} - -// Set58 will set the flag bit value at index 58. -func (f Flags64) Set58() Flags64 { - const mask = Flags64(1) << 58 - return f | mask -} - -// Unset58 will unset the flag bit value at index 58. -func (f Flags64) Unset58() Flags64 { - const mask = Flags64(1) << 58 - return f & ^mask -} - -// Get59 will fetch the flag bit value at index 59. -func (f Flags64) Get59() bool { - const mask = Flags64(1) << 59 - return (f&mask != 0) -} - -// Set59 will set the flag bit value at index 59. -func (f Flags64) Set59() Flags64 { - const mask = Flags64(1) << 59 - return f | mask -} - -// Unset59 will unset the flag bit value at index 59. -func (f Flags64) Unset59() Flags64 { - const mask = Flags64(1) << 59 - return f & ^mask -} - -// Get60 will fetch the flag bit value at index 60. -func (f Flags64) Get60() bool { - const mask = Flags64(1) << 60 - return (f&mask != 0) -} - -// Set60 will set the flag bit value at index 60. -func (f Flags64) Set60() Flags64 { - const mask = Flags64(1) << 60 - return f | mask -} - -// Unset60 will unset the flag bit value at index 60. -func (f Flags64) Unset60() Flags64 { - const mask = Flags64(1) << 60 - return f & ^mask -} - -// Get61 will fetch the flag bit value at index 61. -func (f Flags64) Get61() bool { - const mask = Flags64(1) << 61 - return (f&mask != 0) -} - -// Set61 will set the flag bit value at index 61. -func (f Flags64) Set61() Flags64 { - const mask = Flags64(1) << 61 - return f | mask -} - -// Unset61 will unset the flag bit value at index 61. -func (f Flags64) Unset61() Flags64 { - const mask = Flags64(1) << 61 - return f & ^mask -} - -// Get62 will fetch the flag bit value at index 62. -func (f Flags64) Get62() bool { - const mask = Flags64(1) << 62 - return (f&mask != 0) -} - -// Set62 will set the flag bit value at index 62. -func (f Flags64) Set62() Flags64 { - const mask = Flags64(1) << 62 - return f | mask -} - -// Unset62 will unset the flag bit value at index 62. -func (f Flags64) Unset62() Flags64 { - const mask = Flags64(1) << 62 - return f & ^mask -} - -// Get63 will fetch the flag bit value at index 63. -func (f Flags64) Get63() bool { - const mask = Flags64(1) << 63 - return (f&mask != 0) -} - -// Set63 will set the flag bit value at index 63. -func (f Flags64) Set63() Flags64 { - const mask = Flags64(1) << 63 - return f | mask -} - -// Unset63 will unset the flag bit value at index 63. -func (f Flags64) Unset63() Flags64 { - const mask = Flags64(1) << 63 - return f & ^mask -} - -// String returns a human readable representation of Flags64. -func (f Flags64) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1 + (len("false ") * 64) - 1 + 1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - val = f.Get0() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get32() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get33() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get34() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get35() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get36() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get37() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get38() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get39() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get40() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get41() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get42() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get43() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get44() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get45() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get46() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get47() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get48() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get49() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get50() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get51() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get52() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get53() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get54() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get55() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get56() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get57() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get58() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get59() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get60() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get61() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get62() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get63() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags64. -func (f Flags64) GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags64{") + (len("63=false ") * 64) - 1 + 1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags64{") - - val = f.Get0() - i += copy(buf[i:], "0=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get1() - i += copy(buf[i:], "1=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get2() - i += copy(buf[i:], "2=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get3() - i += copy(buf[i:], "3=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get4() - i += copy(buf[i:], "4=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get5() - i += copy(buf[i:], "5=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get6() - i += copy(buf[i:], "6=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get7() - i += copy(buf[i:], "7=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get8() - i += copy(buf[i:], "8=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get9() - i += copy(buf[i:], "9=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get10() - i += copy(buf[i:], "10=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get11() - i += copy(buf[i:], "11=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get12() - i += copy(buf[i:], "12=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get13() - i += copy(buf[i:], "13=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get14() - i += copy(buf[i:], "14=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get15() - i += copy(buf[i:], "15=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get16() - i += copy(buf[i:], "16=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get17() - i += copy(buf[i:], "17=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get18() - i += copy(buf[i:], "18=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get19() - i += copy(buf[i:], "19=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get20() - i += copy(buf[i:], "20=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get21() - i += copy(buf[i:], "21=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get22() - i += copy(buf[i:], "22=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get23() - i += copy(buf[i:], "23=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get24() - i += copy(buf[i:], "24=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get25() - i += copy(buf[i:], "25=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get26() - i += copy(buf[i:], "26=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get27() - i += copy(buf[i:], "27=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get28() - i += copy(buf[i:], "28=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get29() - i += copy(buf[i:], "29=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get30() - i += copy(buf[i:], "30=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get31() - i += copy(buf[i:], "31=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get32() - i += copy(buf[i:], "32=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get33() - i += copy(buf[i:], "33=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get34() - i += copy(buf[i:], "34=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get35() - i += copy(buf[i:], "35=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get36() - i += copy(buf[i:], "36=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get37() - i += copy(buf[i:], "37=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get38() - i += copy(buf[i:], "38=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get39() - i += copy(buf[i:], "39=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get40() - i += copy(buf[i:], "40=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get41() - i += copy(buf[i:], "41=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get42() - i += copy(buf[i:], "42=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get43() - i += copy(buf[i:], "43=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get44() - i += copy(buf[i:], "44=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get45() - i += copy(buf[i:], "45=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get46() - i += copy(buf[i:], "46=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get47() - i += copy(buf[i:], "47=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get48() - i += copy(buf[i:], "48=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get49() - i += copy(buf[i:], "49=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get50() - i += copy(buf[i:], "50=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get51() - i += copy(buf[i:], "51=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get52() - i += copy(buf[i:], "52=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get53() - i += copy(buf[i:], "53=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get54() - i += copy(buf[i:], "54=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get55() - i += copy(buf[i:], "55=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get56() - i += copy(buf[i:], "56=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get57() - i += copy(buf[i:], "57=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get58() - i += copy(buf[i:], "58=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get59() - i += copy(buf[i:], "59=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get60() - i += copy(buf[i:], "60=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get61() - i += copy(buf[i:], "61=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get62() - i += copy(buf[i:], "62=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - val = f.Get63() - i += copy(buf[i:], "63=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -func bool2str(b bool) string { - if b { - return "true" - } - return "false" -} diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag.tpl b/vendor/codeberg.org/gruf/go-bitutil/flag.tpl deleted file mode 100644 index ac00bfa97..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/flag.tpl +++ /dev/null @@ -1,117 +0,0 @@ -package bitutil - -import ( - "strings" - "unsafe" -) - -{{ range $idx, $size := . }} - -// Flags{{ $size.Size }} is a type-casted unsigned integer with helper -// methods for easily managing up to {{ $size.Size }} bit-flags. -type Flags{{ $size.Size }} uint{{ $size.Size }} - -// Get will fetch the flag bit value at index 'bit'. -func (f Flags{{ $size.Size }}) Get(bit uint8) bool { - mask := Flags{{ $size.Size }}(1) << bit - return (f & mask != 0) -} - -// Set will set the flag bit value at index 'bit'. -func (f Flags{{ $size.Size }}) Set(bit uint8) Flags{{ $size.Size }} { - mask := Flags{{ $size.Size }}(1) << bit - return f | mask -} - -// Unset will unset the flag bit value at index 'bit'. -func (f Flags{{ $size.Size }}) Unset(bit uint8) Flags{{ $size.Size }} { - mask := Flags{{ $size.Size }}(1) << bit - return f & ^mask -} - -{{ range $idx := $size.Bits }} - -// Get{{ $idx }} will fetch the flag bit value at index {{ $idx }}. -func (f Flags{{ $size.Size }}) Get{{ $idx }}() bool { - const mask = Flags{{ $size.Size }}(1) << {{ $idx }} - return (f & mask != 0) -} - -// Set{{ $idx }} will set the flag bit value at index {{ $idx }}. -func (f Flags{{ $size.Size }}) Set{{ $idx }}() Flags{{ $size.Size }} { - const mask = Flags{{ $size.Size }}(1) << {{ $idx }} - return f | mask -} - -// Unset{{ $idx }} will unset the flag bit value at index {{ $idx }}. -func (f Flags{{ $size.Size }}) Unset{{ $idx }}() Flags{{ $size.Size }} { - const mask = Flags{{ $size.Size }}(1) << {{ $idx }} - return f & ^mask -} - -{{ end }} - -// String returns a human readable representation of Flags{{ $size.Size }}. -func (f Flags{{ $size.Size }}) String() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = 1+(len("false ")*{{ $size.Size }})-1+1 - buf = make([]byte, prealloc) - - buf[i] = '{' - i++ - - {{ range $idx := .Bits }} - val = f.Get{{ $idx }}() - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - {{ end }} - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -// GoString returns a more verbose human readable representation of Flags{{ $size.Size }}. -func (f Flags{{ $size.Size }})GoString() string { - var ( - i int - val bool - buf []byte - ) - - // Make a prealloc est. based on longest-possible value - const prealloc = len("bitutil.Flags{{ $size.Size }}{")+(len("{{ sub $size.Size 1 }}=false ")*{{ $size.Size }})-1+1 - buf = make([]byte, prealloc) - - i += copy(buf[i:], "bitutil.Flags{{ $size.Size }}{") - - {{ range $idx := .Bits }} - val = f.Get{{ $idx }}() - i += copy(buf[i:], "{{ $idx }}=") - i += copy(buf[i:], bool2str(val)) - buf[i] = ' ' - i++ - {{ end }} - - buf[i-1] = '}' - buf = buf[:i] - - return *(*string)(unsafe.Pointer(&buf)) -} - -{{ end }} - -func bool2str(b bool) string { - if b { - return "true" - } - return "false" -} \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl b/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl deleted file mode 100644 index e85cc2dff..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/flag_test.tpl +++ /dev/null @@ -1,98 +0,0 @@ -package bitutil_test - -import ( - "strings" - "testing" - - "codeberg.org/gruf/go-bytes" -) - -{{ range $idx, $size := . }} - -func TestFlags{{ $size.Size }}Get(t *testing.T) { - var mask, flags bitutil.Flags{{ $size.Size }} - - {{ range $idx := $size.Bits }} - - mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }} - - flags = 0 - - flags |= mask - if !flags.Get({{ $idx }}) { - t.Error("failed .Get() set Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags &= ^mask - if flags.Get({{ $idx }}) { - t.Error("failed .Get() unset Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = 0 - - flags |= mask - if !flags.Get{{ $idx }}() { - t.Error("failed .Get{{ $idx }}() set Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags &= ^mask - if flags.Get{{ $idx }}() { - t.Error("failed .Get{{ $idx }}() unset Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - {{ end }} -} - -func TestFlags{{ $size.Size }}Set(t *testing.T) { - var mask, flags bitutil.Flags{{ $size.Size }} - - {{ range $idx := $size.Bits }} - - mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }} - - flags = 0 - - flags = flags.Set({{ $idx }}) - if flags & mask == 0 { - t.Error("failed .Set() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = 0 - - flags = flags.Set{{ $idx }}() - if flags & mask == 0 { - t.Error("failed .Set{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - {{ end }} -} - -func TestFlags{{ $size.Size }}Unset(t *testing.T) { - var mask, flags bitutil.Flags{{ $size.Size }} - - {{ range $idx := $size.Bits }} - - mask = bitutil.Flags{{ $size.Size }}(1) << {{ $idx }} - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags = flags.Unset({{ $idx }}) - if flags & mask != 0 { - t.Error("failed .Unset() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - flags = ^bitutil.Flags{{ $size.Size }}(0) - - flags = flags.Unset{{ $idx }}() - if flags & mask != 0 { - t.Error("failed .Unset{{ $idx }}() Flags{{ $size.Size }} bit at index {{ $idx }}") - } - - {{ end }} -} - -{{ end }} \ No newline at end of file diff --git a/vendor/codeberg.org/gruf/go-bitutil/pack.go b/vendor/codeberg.org/gruf/go-bitutil/pack.go deleted file mode 100644 index 2a57d3294..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/pack.go +++ /dev/null @@ -1,85 +0,0 @@ -package bitutil - -// PackInt8s will pack two signed 8bit integers into an unsigned 16bit integer. -func PackInt8s(i1, i2 int8) uint16 { - const bits = 8 - const mask = (1 << bits) - 1 - return uint16(i1)<> bits), int8(i & mask) -} - -// PackInt16s will pack two signed 16bit integers into an unsigned 32bit integer. -func PackInt16s(i1, i2 int16) uint32 { - const bits = 16 - const mask = (1 << bits) - 1 - return uint32(i1)<> bits), int16(i & mask) -} - -// PackInt32s will pack two signed 32bit integers into an unsigned 64bit integer. -func PackInt32s(i1, i2 int32) uint64 { - const bits = 32 - const mask = (1 << bits) - 1 - return uint64(i1)<> bits), int32(i & mask) -} - -// PackUint8s will pack two unsigned 8bit integers into an unsigned 16bit integer. -func PackUint8s(u1, u2 uint8) uint16 { - const bits = 8 - const mask = (1 << bits) - 1 - return uint16(u1)<> bits), uint8(u & mask) -} - -// PackUint16s will pack two unsigned 16bit integers into an unsigned 32bit integer. -func PackUint16s(u1, u2 uint16) uint32 { - const bits = 16 - const mask = (1 << bits) - 1 - return uint32(u1)<> bits), uint16(u & mask) -} - -// PackUint32s will pack two unsigned 32bit integers into an unsigned 64bit integer. -func PackUint32s(u1, u2 uint32) uint64 { - const bits = 32 - const mask = (1 << bits) - 1 - return uint64(u1)<> bits), uint32(u & mask) -} diff --git a/vendor/codeberg.org/gruf/go-bitutil/test.tpl b/vendor/codeberg.org/gruf/go-bitutil/test.tpl deleted file mode 100644 index 4e659d81f..000000000 --- a/vendor/codeberg.org/gruf/go-bitutil/test.tpl +++ /dev/null @@ -1,60 +0,0 @@ -package atomics_test - -import ( - "atomic" - "unsafe" - "testing" - - "codeberg.org/gruf/go-atomics" -) - -func Test{{ .Name }}StoreLoad(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if !({{ call .Compare "val.Load()" "test.V1" }}) { - t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V1) - } - - val.Store(test.V2) - - if !({{ call .Compare "val.Load()" "test.V2" }}) { - t.Fatalf("failed testing .Store and .Load: expect=%v actual=%v", val.Load(), test.V2) - } - } -} - -func Test{{ .Name }}CAS(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if val.CAS(test.V2, test.V1) { - t.Fatalf("failed testing negative .CAS: test=%+v state=%v", test, val.Load()) - } - - if !val.CAS(test.V1, test.V2) { - t.Fatalf("failed testing positive .CAS: test=%+v state=%v", test, val.Load()) - } - } -} - -func Test{{ .Name }}Swap(t *testing.T) { - for _, test := range {{ .Name }}Tests { - val := atomics.New{{ .Name }}() - - val.Store(test.V1) - - if !({{ call .Compare "val.Swap(test.V2)" "test.V1" }}) { - t.Fatal("failed testing .Swap") - } - - if !({{ call .Compare "val.Swap(test.V1)" "test.V2" }}) { - t.Fatal("failed testing .Swap") - } - } -} - diff --git a/vendor/github.com/technologize/otel-go-contrib/LICENSE b/vendor/github.com/technologize/otel-go-contrib/LICENSE deleted file mode 100644 index 261eeb9e9..000000000 --- a/vendor/github.com/technologize/otel-go-contrib/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/config.go b/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/config.go deleted file mode 100644 index f33fe38ed..000000000 --- a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/config.go +++ /dev/null @@ -1,45 +0,0 @@ -package otelginmetrics - -import ( - "net/http" - - "go.opentelemetry.io/otel/attribute" - semconv "go.opentelemetry.io/otel/semconv/v1.7.0" -) - -type config struct { - recordInFlight bool - recordSize bool - recordDuration bool - groupedStatus bool - recorder Recorder - attributes func(serverName, route string, request *http.Request) []attribute.KeyValue - shouldRecord func(serverName, route string, request *http.Request) bool -} - -func defaultConfig() *config { - return &config{ - recordInFlight: true, - recordDuration: true, - recordSize: true, - groupedStatus: true, - attributes: DefaultAttributes, - shouldRecord: func(_, _ string, _ *http.Request) bool { - return true - }, - } -} - -var DefaultAttributes = func(serverName, route string, request *http.Request) []attribute.KeyValue { - attrs := []attribute.KeyValue{ - semconv.HTTPMethodKey.String(request.Method), - } - - if serverName != "" { - attrs = append(attrs, semconv.HTTPServerNameKey.String(serverName)) - } - if route != "" { - attrs = append(attrs, semconv.HTTPRouteKey.String(route)) - } - return attrs -} diff --git a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/middleware.go b/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/middleware.go deleted file mode 100644 index 85479c7f1..000000000 --- a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/middleware.go +++ /dev/null @@ -1,94 +0,0 @@ -package otelginmetrics - -import ( - "net/http" - "time" - - "github.com/gin-gonic/gin" - semconv "go.opentelemetry.io/otel/semconv/v1.7.0" -) - -// Middleware returns middleware that will trace incoming requests. -// The service parameter should describe the name of the (virtual) -// server handling the request. -func Middleware(service string, options ...Option) gin.HandlerFunc { - cfg := defaultConfig() - for _, option := range options { - option.apply(cfg) - } - recorder := cfg.recorder - if recorder == nil { - recorder = GetRecorder("") - } - return func(ginCtx *gin.Context) { - - ctx := ginCtx.Request.Context() - - route := ginCtx.FullPath() - if len(route) <= 0 { - route = "nonconfigured" - } - if !cfg.shouldRecord(service, route, ginCtx.Request) { - ginCtx.Next() - return - } - - start := time.Now() - reqAttributes := cfg.attributes(service, route, ginCtx.Request) - - if cfg.recordInFlight { - recorder.AddInflightRequests(ctx, 1, reqAttributes) - defer recorder.AddInflightRequests(ctx, -1, reqAttributes) - } - - defer func() { - - resAttributes := append(reqAttributes[0:0], reqAttributes...) - - if cfg.groupedStatus { - code := int(ginCtx.Writer.Status()/100) * 100 - resAttributes = append(resAttributes, semconv.HTTPStatusCodeKey.Int(code)) - } else { - resAttributes = append(resAttributes, semconv.HTTPAttributesFromHTTPStatusCode(ginCtx.Writer.Status())...) - } - - recorder.AddRequests(ctx, 1, resAttributes) - - if cfg.recordSize { - requestSize := computeApproximateRequestSize(ginCtx.Request) - recorder.ObserveHTTPRequestSize(ctx, requestSize, resAttributes) - recorder.ObserveHTTPResponseSize(ctx, int64(ginCtx.Writer.Size()), resAttributes) - } - - if cfg.recordDuration { - recorder.ObserveHTTPRequestDuration(ctx, time.Since(start), resAttributes) - } - }() - - ginCtx.Next() - } -} - -func computeApproximateRequestSize(r *http.Request) int64 { - s := 0 - if r.URL != nil { - s = len(r.URL.Path) - } - - s += len(r.Method) - s += len(r.Proto) - for name, values := range r.Header { - s += len(name) - for _, value := range values { - s += len(value) - } - } - s += len(r.Host) - - // N.B. r.Form and r.MultipartForm are assumed to be included in r.URL. - - if r.ContentLength != -1 { - s += int(r.ContentLength) - } - return int64(s) -} diff --git a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/option.go b/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/option.go deleted file mode 100644 index 144ef9378..000000000 --- a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/option.go +++ /dev/null @@ -1,74 +0,0 @@ -package otelginmetrics - -import ( - "net/http" - - "go.opentelemetry.io/otel/attribute" -) - -// Option applies a configuration to the given config -type Option interface { - apply(cfg *config) -} - -type optionFunc func(cfg *config) - -func (fn optionFunc) apply(cfg *config) { - fn(cfg) -} - -// WithAttributes sets a func using which what attributes to be recorded can be specified. -// By default the DefaultAttributes is used -func WithAttributes(attributes func(serverName, route string, request *http.Request) []attribute.KeyValue) Option { - return optionFunc(func(cfg *config) { - cfg.attributes = attributes - }) -} - -// WithRecordInFlight determines whether to record In Flight Requests or not -// By default the recordInFlight is true -func WithRecordInFlightDisabled() Option { - return optionFunc(func(cfg *config) { - cfg.recordInFlight = false - }) -} - -// WithRecordDuration determines whether to record Duration of Requests or not -// By default the recordDuration is true -func WithRecordDurationDisabled() Option { - return optionFunc(func(cfg *config) { - cfg.recordDuration = false - }) -} - -// WithRecordSize determines whether to record Size of Requests and Responses or not -// By default the recordSize is true -func WithRecordSizeDisabled() Option { - return optionFunc(func(cfg *config) { - cfg.recordSize = false - }) -} - -// WithGroupedStatus determines whether to group the response status codes or not. If true 2xx, 3xx will be stored -// By default the groupedStatus is true -func WithGroupedStatusDisabled() Option { - return optionFunc(func(cfg *config) { - cfg.groupedStatus = false - }) -} - -// WithRecorder sets a recorder for recording requests -// By default the open telemetry recorder is used -func WithRecorder(recorder Recorder) Option { - return optionFunc(func(cfg *config) { - cfg.recorder = recorder - }) -} - -// WithShouldRecordFunc sets a func using which whether a record should be recorded -// By default the all api calls are recorded -func WithShouldRecordFunc(shouldRecord func(serverName, route string, request *http.Request) bool) Option { - return optionFunc(func(cfg *config) { - cfg.shouldRecord = shouldRecord - }) -} diff --git a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/otelrecorder.go b/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/otelrecorder.go deleted file mode 100644 index efdc96ffd..000000000 --- a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/otelrecorder.go +++ /dev/null @@ -1,70 +0,0 @@ -package otelginmetrics - -import ( - "context" - "time" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/metric" -) - -const instrumentationName = "github.com/technologize/otel-go-contrib/otelginmetrics" - -// Recorder knows how to record and measure the metrics. This -// has the required methods to be used with the HTTP -// middlewares. -type otelRecorder struct { - attemptsCounter metric.Int64UpDownCounter - totalDuration metric.Int64Histogram - activeRequestsCounter metric.Int64UpDownCounter - requestSize metric.Int64Histogram - responseSize metric.Int64Histogram -} - -func GetRecorder(metricsPrefix string) Recorder { - metricName := func(metricName string) string { - if len(metricsPrefix) > 0 { - return metricsPrefix + "." + metricName - } - return metricName - } - meter := otel.Meter(instrumentationName, metric.WithInstrumentationVersion(SemVersion())) - attemptsCounter, _ := meter.Int64UpDownCounter(metricName("http.server.request_count"), metric.WithDescription("Number of Requests"), metric.WithUnit("Count")) - totalDuration, _ := meter.Int64Histogram(metricName("http.server.duration"), metric.WithDescription("Time Taken by request"), metric.WithUnit("Milliseconds")) - activeRequestsCounter, _ := meter.Int64UpDownCounter(metricName("http.server.active_requests"), metric.WithDescription("Number of requests inflight"), metric.WithUnit("Count")) - requestSize, _ := meter.Int64Histogram(metricName("http.server.request_content_length"), metric.WithDescription("Request Size"), metric.WithUnit("Bytes")) - responseSize, _ := meter.Int64Histogram(metricName("http.server.response_content_length"), metric.WithDescription("Response Size"), metric.WithUnit("Bytes")) - return &otelRecorder{ - attemptsCounter: attemptsCounter, - totalDuration: totalDuration, - activeRequestsCounter: activeRequestsCounter, - requestSize: requestSize, - responseSize: responseSize, - } -} - -// AddRequests increments the number of requests being processed. -func (r *otelRecorder) AddRequests(ctx context.Context, quantity int64, attributes []attribute.KeyValue) { - r.attemptsCounter.Add(ctx, quantity, metric.WithAttributes(attributes...)) -} - -// ObserveHTTPRequestDuration measures the duration of an HTTP request. -func (r *otelRecorder) ObserveHTTPRequestDuration(ctx context.Context, duration time.Duration, attributes []attribute.KeyValue) { - r.totalDuration.Record(ctx, int64(duration/time.Millisecond), metric.WithAttributes(attributes...)) -} - -// ObserveHTTPRequestSize measures the size of an HTTP request in bytes. -func (r *otelRecorder) ObserveHTTPRequestSize(ctx context.Context, sizeBytes int64, attributes []attribute.KeyValue) { - r.requestSize.Record(ctx, sizeBytes, metric.WithAttributes(attributes...)) -} - -// ObserveHTTPResponseSize measures the size of an HTTP response in bytes. -func (r *otelRecorder) ObserveHTTPResponseSize(ctx context.Context, sizeBytes int64, attributes []attribute.KeyValue) { - r.responseSize.Record(ctx, sizeBytes, metric.WithAttributes(attributes...)) -} - -// AddInflightRequests increments and decrements the number of inflight request being processed. -func (r *otelRecorder) AddInflightRequests(ctx context.Context, quantity int64, attributes []attribute.KeyValue) { - r.activeRequestsCounter.Add(ctx, quantity, metric.WithAttributes(attributes...)) -} diff --git a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/recorder.go b/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/recorder.go deleted file mode 100644 index 7fadeff38..000000000 --- a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/recorder.go +++ /dev/null @@ -1,25 +0,0 @@ -package otelginmetrics - -import ( - "context" - "time" - - "go.opentelemetry.io/otel/attribute" -) - -type Recorder interface { - // AddRequests increments the number of requests being processed. - AddRequests(ctx context.Context, quantity int64, attributes []attribute.KeyValue) - - // ObserveHTTPRequestDuration measures the duration of an HTTP request. - ObserveHTTPRequestDuration(ctx context.Context, duration time.Duration, attributes []attribute.KeyValue) - - // ObserveHTTPRequestSize measures the size of an HTTP request in bytes. - ObserveHTTPRequestSize(ctx context.Context, sizeBytes int64, attributes []attribute.KeyValue) - - // ObserveHTTPResponseSize measures the size of an HTTP response in bytes. - ObserveHTTPResponseSize(ctx context.Context, sizeBytes int64, attributes []attribute.KeyValue) - - // AddInflightRequests increments and decrements the number of inflight request being processed. - AddInflightRequests(ctx context.Context, quantity int64, attributes []attribute.KeyValue) -} diff --git a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/version.go b/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/version.go deleted file mode 100644 index 323e1a4c1..000000000 --- a/vendor/github.com/technologize/otel-go-contrib/otelginmetrics/version.go +++ /dev/null @@ -1,11 +0,0 @@ -package otelginmetrics - -// Version is the current release version of the gin instrumentation. -func Version() string { - return "1.0.0" -} - -// SemVersion is the semantic version to be supplied to tracer/meter creation. -func SemVersion() string { - return "semver:" + Version() -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5defdf9b4..ac4bab587 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -221,9 +221,6 @@ code.superseriousbusiness.org/oauth2/v4/generates code.superseriousbusiness.org/oauth2/v4/manage code.superseriousbusiness.org/oauth2/v4/models code.superseriousbusiness.org/oauth2/v4/server -# codeberg.org/gruf/go-bitutil v1.1.0 -## explicit; go 1.19 -codeberg.org/gruf/go-bitutil # codeberg.org/gruf/go-bytesize v1.0.4 ## explicit; go 1.17 codeberg.org/gruf/go-bytesize @@ -870,9 +867,6 @@ github.com/tdewolff/parse/v2 github.com/tdewolff/parse/v2/buffer github.com/tdewolff/parse/v2/html github.com/tdewolff/parse/v2/strconv -# github.com/technologize/otel-go-contrib v1.1.1 -## explicit; go 1.17 -github.com/technologize/otel-go-contrib/otelginmetrics # github.com/temoto/robotstxt v1.1.2 ## explicit; go 1.11 github.com/temoto/robotstxt