├── .github ├── FUNDING.yml └── workflows │ └── test.yaml ├── .gitignore ├── .vscode └── launch.json ├── CNAME ├── LICENSE ├── README.md ├── application ├── application.go ├── application_test.go ├── doc.go └── group.go ├── cfg ├── config.go ├── config_test.go ├── doc.go ├── option.go ├── validation.go └── validation_test.go ├── codegen ├── bundle │ ├── api │ │ ├── clients-gen.functions.txt │ │ ├── clients-gen.txt │ │ ├── clients-gen.webs.txt │ │ ├── imports-gen.txt │ │ └── type.txt │ ├── app │ │ └── main-gen.txt │ ├── integration-gen_test.configs.txt │ ├── integration-gen_test.events.txt │ ├── integration-gen_test.functions.txt │ ├── integration-gen_test.metrics.txt │ ├── integration-gen_test.tickers.txt │ ├── integration-gen_test.txt │ ├── integration-gen_test.webs.txt │ ├── integration_test.append.txt │ ├── integration_test.txt │ ├── intermediate │ │ ├── intermediate-gen.configs.txt │ │ ├── intermediate-gen.functions.txt │ │ ├── intermediate-gen.metrics.txt │ │ ├── intermediate-gen.txt │ │ └── mock-gen.txt │ ├── resources │ │ └── embed-gen.txt │ ├── service-gen.txt │ ├── service.append.txt │ ├── service.txt │ ├── service.yaml.txt │ ├── version-gen.txt │ └── version-gen_test.txt ├── generator.go ├── generator_test.go ├── main.go ├── make.go ├── make_test.go ├── printer.go ├── printer_test.go ├── spec │ ├── argument.go │ ├── common.go │ ├── general.go │ ├── general_test.go │ ├── handler.go │ ├── service.go │ ├── service_test.go │ ├── signature.go │ ├── signature_test.go │ ├── type.go │ └── version.go ├── tester │ ├── app │ │ └── tester │ │ │ └── main-gen.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ ├── 3.txt │ │ ├── embed-gen.go │ │ ├── static │ │ │ ├── 1.txt │ │ │ └── sub │ │ │ │ └── 2.txt │ │ └── strings.yaml │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── testerapi │ │ ├── clients-gen.go │ │ ├── xycoord.go │ │ └── xyline.go │ ├── version-gen.go │ └── version-gen_test.go ├── texttemplate.go ├── texttemplate_test.go ├── yamlfile.go └── yamlfile_test.go ├── connector ├── config.go ├── config_test.go ├── connector.go ├── connector_test.go ├── control.go ├── control_test.go ├── doc.go ├── fragment.go ├── fragment_test.go ├── lifecycle.go ├── lifecycle_test.go ├── logger.go ├── logger_test.go ├── metrics.go ├── metrics_test.go ├── muffler.go ├── publish.go ├── publish_test.go ├── res.go ├── res_test.go ├── selectiveprocessor.go ├── selectiveprocessor_test.go ├── subjects.go ├── subjects_test.go ├── subscribe.go ├── subscribe_test.go ├── testdata │ ├── res.html │ ├── res.txt │ └── strings.yaml ├── time.go ├── time_test.go ├── tracer.go └── tracer_test.go ├── copyright.go ├── coreservices ├── configurator │ ├── app │ │ └── configurator │ │ │ └── main-gen.go │ ├── configuratorapi │ │ └── clients-gen.go │ ├── doc.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── repository.go │ ├── repository_test.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── service_test.go │ ├── version-gen.go │ └── version-gen_test.go ├── control │ ├── app │ │ └── control │ │ │ └── main-gen.go │ ├── controlapi │ │ ├── clientext.go │ │ └── clients-gen.go │ ├── doc.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── httpegress │ ├── app │ │ └── httpegress │ │ │ └── main-gen.go │ ├── doc.go │ ├── httpegressapi │ │ ├── client.go │ │ └── clients-gen.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── httpingress │ ├── app │ │ └── httpingress │ │ │ └── main-gen.go │ ├── doc.go │ ├── httpingressapi │ │ └── clients-gen.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── logwriter.go │ ├── middleware.go │ ├── middleware │ │ ├── authorization.go │ │ ├── authorization_test.go │ │ ├── blockedpaths.go │ │ ├── cachecontrol.go │ │ ├── chain.go │ │ ├── chain_test.go │ │ ├── charsetutf8.go │ │ ├── compress.go │ │ ├── cors.go │ │ ├── defaultfavicon.go │ │ ├── defaultfavicon.ico │ │ ├── errorpageredirect.go │ │ ├── errorpageredirect_test.go │ │ ├── errorprinter.go │ │ ├── group.go │ │ ├── internalheaders.go │ │ ├── logger.go │ │ ├── noop.go │ │ ├── onroute.go │ │ ├── rootpath.go │ │ ├── secureredirect.go │ │ ├── timeout.go │ │ └── xforwarded.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── service_test.go │ ├── version-gen.go │ └── version-gen_test.go ├── metrics │ ├── app │ │ └── metrics │ │ │ └── main-gen.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── metricsapi │ │ └── clients-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── openapiportal │ ├── app │ │ └── openapiportal │ │ │ └── main-gen.go │ ├── doc.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── openapiportalapi │ │ └── clients-gen.go │ ├── resources │ │ ├── embed-gen.go │ │ └── list.html │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── smtpingress │ ├── app │ │ └── smtpingress │ │ │ └── main-gen.go │ ├── doc.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── loghook.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── smtpingressapi │ │ ├── clients-gen.go │ │ └── email.go │ ├── version-gen.go │ └── version-gen_test.go └── tokenissuer │ ├── app │ ├── authtokenissuer │ │ └── main-gen.go │ └── tokenissuer │ │ └── main-gen.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ ├── intermediate-gen.go │ └── mock-gen.go │ ├── resources │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── tokenissuerapi │ └── clients-gen.go │ ├── version-gen.go │ └── version-gen_test.go ├── dlru ├── cache.go ├── cache_test.go ├── doc.go └── option.go ├── docs ├── blocks │ ├── ack-or-fail-1.drawio.svg │ ├── ack-or-fail-2.drawio.svg │ ├── ack-or-fail-3.drawio.svg │ ├── ack-or-fail-4.drawio.svg │ ├── ack-or-fail.md │ ├── authorization-1.drawio.svg │ ├── authorization.md │ ├── client-stubs.md │ ├── codegen-1.drawio.svg │ ├── codegen-2.drawio.svg │ ├── codegen.md │ ├── configuration.md │ ├── connectivity-liveness-test.md │ ├── discovery-1.drawio.svg │ ├── discovery.md │ ├── distrib-cache-1.drawio.svg │ ├── distrib-cache-2.drawio.svg │ ├── distrib-cache-3.drawio.svg │ ├── distrib-cache-4.drawio.svg │ ├── distrib-cache-5.drawio.svg │ ├── distrib-cache.md │ ├── distrib-tracing-1.png │ ├── distrib-tracing-2.png │ ├── distrib-tracing.md │ ├── embedded-res.md │ ├── error-capture.md │ ├── events-1.drawio.svg │ ├── events-2.drawio.svg │ ├── events.md │ ├── graceful-shutdown.md │ ├── i18n.md │ ├── integration-testing-1.drawio.svg │ ├── integration-testing.md │ ├── layers-1.drawio.svg │ ├── layers.md │ ├── lb-1.drawio.svg │ ├── lb-2.drawio.svg │ ├── lb.md │ ├── locality-aware-routing-1.drawio.svg │ ├── locality-aware-routing.md │ ├── logging.md │ ├── metrics-1.png │ ├── metrics.md │ ├── multicast.md │ ├── multiplexed-1.drawio.svg │ ├── multiplexed-2.drawio.svg │ ├── multiplexed.md │ ├── openapi.md │ ├── skeleton-code.md │ ├── tickers.md │ ├── time-budget-1.drawio.svg │ ├── time-budget-2.drawio.svg │ ├── time-budget-3.drawio.svg │ ├── time-budget.md │ ├── topology-1.drawio.svg │ ├── topology-2.drawio.svg │ ├── topology-3.drawio.svg │ ├── topology-4.drawio.svg │ ├── topology-5.drawio.svg │ ├── topology-6.drawio.svg │ ├── topology.md │ ├── unicast-1.drawio.svg │ ├── unicast.md │ └── uniform-code.md ├── general │ ├── milestones.md │ ├── mission-statement.md │ └── third-party-oss.md ├── howto │ ├── create-microservice.md │ ├── enabling-auth.md │ ├── first-service-1.png │ ├── first-service.md │ ├── new-project.md │ ├── quick-start-1.png │ ├── quick-start.md │ └── self-explore.md ├── structure │ ├── application.md │ ├── cfg.md │ ├── codegen.md │ ├── connector.md │ ├── coreservices-configurator.md │ ├── coreservices-control.md │ ├── coreservices-httpegress.md │ ├── coreservices-httpingress-1.drawio.svg │ ├── coreservices-httpingress-2.drawio.svg │ ├── coreservices-httpingress-3.drawio.svg │ ├── coreservices-httpingress-middleware.md │ ├── coreservices-httpingress.md │ ├── coreservices-metrics-1.drawio.svg │ ├── coreservices-metrics.md │ ├── coreservices-openapiportal.md │ ├── coreservices-smtpingress.md │ ├── coreservices-tokenissuer.md │ ├── coreservices.md │ ├── dlru.md │ ├── env.md │ ├── errors.md │ ├── examples-browser.md │ ├── examples-calculator.md │ ├── examples-directory-1.png │ ├── examples-directory-2.png │ ├── examples-directory.md │ ├── examples-events.md │ ├── examples-hello-1.png │ ├── examples-hello.md │ ├── examples-helloworld.md │ ├── examples-login.md │ ├── examples-messaging.md │ ├── examples.md │ ├── frame.md │ ├── httpx.md │ ├── lru.md │ ├── openapi.md │ ├── packages.md │ ├── pub.md │ ├── rand.md │ ├── service.md │ ├── sub.md │ ├── trc.md │ └── utils.md └── tech │ ├── control-subs.md │ ├── deployments.md │ ├── encapsulation.md │ ├── envars.md │ ├── http-arguments.md │ ├── json-vs-protobuf.md │ ├── local-dev.md │ ├── nats-connection.md │ ├── nutshell-1.drawio.svg │ ├── out-of-scope.md │ ├── path-arguments.md │ ├── ports-1.drawio.svg │ ├── ports.md │ ├── rpc-vs-rest.md │ ├── service-yaml-1.drawio.svg │ └── service-yaml.md ├── env ├── env.go ├── env_test.go └── testdata │ └── env.yaml ├── errors ├── doc.go ├── errors.go ├── errors_test.go ├── stackframe.go └── tracederror.go ├── examples ├── browser │ ├── app │ │ └── browser │ │ │ └── main-gen.go │ ├── browserapi │ │ └── clients-gen.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── calculator │ ├── app │ │ └── calculator │ │ │ └── main-gen.go │ ├── calculatorapi │ │ ├── clients-gen.go │ │ └── point.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── directory │ ├── app │ │ └── directory │ │ │ └── main-gen.go │ ├── directoryapi │ │ ├── clients-gen.go │ │ ├── person.go │ │ └── personkey.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ ├── embed-gen.go │ │ └── webui.html │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── eventsink │ ├── app │ │ └── eventsink │ │ │ └── main-gen.go │ ├── doc.go │ ├── eventsinkapi │ │ └── clients-gen.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── eventsource │ ├── app │ │ └── eventsource │ │ │ └── main-gen.go │ ├── doc.go │ ├── eventsourceapi │ │ └── clients-gen.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── hello │ ├── app │ │ └── hello │ │ │ └── main-gen.go │ ├── doc.go │ ├── helloapi │ │ └── clients-gen.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ ├── bus.png │ │ ├── embed-gen.go │ │ └── strings.yaml │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── helloworld │ ├── app │ │ └── helloworld │ │ │ └── main-gen.go │ ├── doc.go │ ├── helloworldapi │ │ └── clients-gen.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── resources │ │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── login │ ├── actor.go │ ├── app │ │ └── login │ │ │ └── main-gen.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ │ ├── intermediate-gen.go │ │ └── mock-gen.go │ ├── loginapi │ │ └── clients-gen.go │ ├── resources │ │ ├── admin-only.html │ │ ├── embed-gen.go │ │ ├── login.html │ │ ├── manager-only.html │ │ └── welcome.html │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go └── messaging │ ├── app │ └── messaging │ │ └── main-gen.go │ ├── doc.go │ ├── integration-gen_test.go │ ├── integration_test.go │ ├── intermediate │ ├── intermediate-gen.go │ └── mock-gen.go │ ├── messagingapi │ └── clients-gen.go │ ├── resources │ └── embed-gen.go │ ├── service-gen.go │ ├── service.go │ ├── service.yaml │ ├── version-gen.go │ └── version-gen_test.go ├── frame ├── frame.go └── frame_test.go ├── go.mod ├── go.sum ├── httpx ├── address.go ├── bodyreader.go ├── bodyreader_test.go ├── copy.go ├── deepobject.go ├── deepobject_test.go ├── defragrequest.go ├── defragresponse.go ├── doc.go ├── frag_test.go ├── fragrequest.go ├── fragresponse.go ├── path.go ├── path_test.go ├── qargs.go ├── qargs_test.go ├── request.go ├── request_test.go ├── requestparser.go ├── requestparser_test.go ├── responserecorder.go └── responserecorder_test.go ├── lru ├── cache.go ├── cache_test.go └── option.go ├── main ├── config.yaml ├── env.yaml └── main.go ├── microbus-logo.svg ├── openapi ├── endpoint.go ├── oapidoc.go └── service.go ├── pub ├── doc.go ├── option.go ├── request.go ├── request_test.go ├── response.go └── response_test.go ├── rand ├── doc.go ├── rand.go └── rand_test.go ├── service └── interfaces.go ├── setup ├── grafana │ └── dashboards │ │ ├── dashboards.yaml │ │ ├── microservice-focus.json │ │ └── system-overview.json └── microbus.yaml ├── sub ├── doc.go ├── option.go ├── subscription.go └── subscription_test.go ├── trc ├── doc.go ├── option.go └── span.go └── utils ├── boolexp.go ├── boolexp_test.go ├── doc.go ├── panic.go ├── sourcecodehash.go ├── sourcecodehash_test.go ├── strings.go ├── strings_test.go ├── syncmap.go ├── validations.go └── validations_test.go /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: # Replace with a single Buy Me a Coffee username 14 | custom: ['https://www.microbus.io/contribute'] 15 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: "Test" 2 | on: 3 | pull_request: 4 | types: [opened, reopened, edited] 5 | push: 6 | branches: 7 | - "main" 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | name: "Run tests" 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Create NATS cluster 16 | uses: onichandame/nats-action@master 17 | with: 18 | port: 4222 19 | - uses: actions/setup-go@v4 20 | with: 21 | go-version-file: 'go.mod' 22 | cache: true 23 | cache-dependency-path: go.sum 24 | - name: "Show version" 25 | run: go version 26 | - name: "Run tests" 27 | run: go test -count 1 -timeout 30s -cover ./... 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | nats-server 8 | 9 | # Test binary, built with `go test -c` 10 | *.test 11 | 12 | # Output of the go coverage tool, specifically when used with LiteIDE 13 | *.out 14 | 15 | # Dependency directories (remove the comment below to include it) 16 | # vendor/ 17 | 18 | # Ignore GoLand specific folders 19 | .idea/ 20 | 21 | # Other 22 | .DS_Store 23 | main/main 24 | main/__debug_bin* 25 | *.drawio.svg.bkp 26 | *.drawio.svg.dtmp 27 | *.drawio.bkp 28 | *.drawio.dtmp 29 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "name": "Main Example", 10 | "type": "go", 11 | "request": "launch", 12 | "mode": "auto", 13 | "program": "${workspaceFolder}/main", 14 | "cwd": "${workspaceFolder}/main" 15 | }, 16 | { 17 | "name": "Codegen", 18 | "type": "go", 19 | "request": "launch", 20 | "mode": "auto", 21 | "program": "${workspaceFolder}/codegen", 22 | "cwd": "${workspaceFolder}/examples/calculator", 23 | "env": {"CODEGEN": "-f -v"} 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | docs.microbus.io -------------------------------------------------------------------------------- /application/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Application is a collection of microservices that run in a single process and share the same lifecycle 19 | */ 20 | package application 21 | -------------------------------------------------------------------------------- /cfg/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package cfg is used for defining configuration properties. 19 | It contains the options to use in Connector.DefineConfig 20 | */ 21 | package cfg 22 | -------------------------------------------------------------------------------- /codegen/bundle/api/imports-gen.txt: -------------------------------------------------------------------------------- 1 | // Code generated by Microbus. DO NOT EDIT. 2 | 3 | package {{ .PackagePathSuffix }}api 4 | 5 | import ( 6 | {{- range $i, $t := .Types }}{{ if not .Exists }}{{ if .PackagePath }} 7 | {{ .PackagePathSuffix }}_{{ Add $i 1 }} "{{ .PackagePath }}" 8 | {{- end }}{{ end }}{{ end }} 9 | ) 10 | 11 | {{- range $i, $t := .Types }}{{ if not .Exists }}{{ if .PackagePath }} 12 | 13 | type {{ .Name }} = {{ .PackagePathSuffix }}_{{ Add $i 1 }}.{{ .Name }} 14 | {{- end }}{{ end }}{{ end }} 15 | -------------------------------------------------------------------------------- /codegen/bundle/api/type.txt: -------------------------------------------------------------------------------- 1 | package {{ .PackagePathSuffix }}api 2 | 3 | // {{ .Name }} 4 | type {{ .Name }} struct { 5 | // TO{{/**/}}DO: define fields of type {{ .Name }} 6 | // Field int `json:"field,omitzero" jsonschema:"description=Number,example=7,default=0,required=true"` 7 | } 8 | -------------------------------------------------------------------------------- /codegen/bundle/app/main-gen.txt: -------------------------------------------------------------------------------- 1 | // Code generated by Microbus. DO NOT EDIT. 2 | 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | 9 | "github.com/microbus-io/fabric/application" 10 | 11 | "{{ .PackagePath }}" 12 | ) 13 | 14 | // main runs an app containing only the {{ .General.Host }} service. 15 | func main() { 16 | app := application.New() 17 | app.Add({{ .PackagePathSuffix }}.NewService()) 18 | err := app.Run() 19 | if err != nil { 20 | fmt.Fprintf(os.Stderr, "%+v", err) 21 | os.Exit(19) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /codegen/bundle/integration_test.txt: -------------------------------------------------------------------------------- 1 | package {{ .PackagePathSuffix }} 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/microbus-io/testarossa" 7 | 8 | "github.com/microbus-io/fabric/service" 9 | 10 | "{{ .PackageDir }}/{{ .PackageDirSuffix }}api" 11 | ) 12 | 13 | var ( 14 | _ *testing.T 15 | _ testarossa.TestingT 16 | _ service.Service 17 | _ *{{ .PackagePathSuffix }}api.Client 18 | ) 19 | 20 | // Initialize starts up the testing app. 21 | func Initialize() (err error) { 22 | // Add microservices to the testing app 23 | err = App.AddAndStartup( 24 | // downstream.NewService().Init(func(svc *downstream.Service) {}), 25 | 26 | Svc.Init(func(svc *Service) { 27 | // Initialize the microservice under test 28 | {{- range .Configs }} 29 | // svc.Set{{ .Name }}({{ .Out "name" }}) 30 | {{- end}} 31 | }), 32 | ) 33 | if err != nil { 34 | return err 35 | } 36 | return nil 37 | } 38 | 39 | // Terminate gets called after the testing app shut down. 40 | func Terminate() (err error) { 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /codegen/bundle/intermediate/intermediate-gen.configs.txt: -------------------------------------------------------------------------------- 1 | 2 | // doOnConfigChanged is called when the config of the microservice changes. 3 | func (svc *Intermediate) doOnConfigChanged(ctx context.Context, changed func(string) bool) (err error) { 4 | {{- range .Configs}}{{ if .Callback}} 5 | if changed("{{ .Name}}") { 6 | err := svc.impl.OnChanged{{ .Name}}(ctx) 7 | if err != nil { 8 | return err // No trace 9 | } 10 | } 11 | {{- end}}{{- end}} 12 | return nil 13 | } 14 | {{ range .Configs}} 15 | /* 16 | {{ .Description }} 17 | */ 18 | func (svc *Intermediate) {{ .Name }}() ({{ .Out "name type" }}) { 19 | _val := svc.Config("{{ .Name }}") 20 | 21 | {{- with index .Signature.OutputArgs 0}} 22 | 23 | {{- if eq .Type "string"}} 24 | return _val{{ end }} 25 | 26 | {{- if eq .Type "int"}} 27 | _i, _ := strconv.ParseInt(_val, 10, 64) 28 | return int(_i){{ end }} 29 | 30 | {{- if eq .Type "bool"}} 31 | _b, _ := strconv.ParseBool(_val) 32 | return _b{{ end }} 33 | 34 | {{- if eq .Type "time.Duration"}} 35 | _dur, _ := time.ParseDuration(_val) 36 | return _dur{{ end }} 37 | 38 | {{- if eq .Type "float64"}} 39 | _f64, _ := time.ParseFloat(_val, 64) 40 | return _f64{{ end }} 41 | 42 | {{- end }} 43 | } 44 | 45 | /* 46 | Set{{ .Name }} sets the value of the configuration property. 47 | This action is restricted to the TESTING deployment in which the fetching of values from the configurator is disabled. 48 | 49 | {{ .Description }} 50 | */ 51 | func (svc *Intermediate) Set{{ .Name }}({{ .Out "name type" }}) error { 52 | return svc.SetConfig("{{ .Name }}", utils.AnyToString({{ (index .Signature.OutputArgs 0).Name }})) 53 | } 54 | {{ end }} -------------------------------------------------------------------------------- /codegen/bundle/resources/embed-gen.txt: -------------------------------------------------------------------------------- 1 | // Code generated by Microbus. DO NOT EDIT. 2 | 3 | package resources 4 | 5 | import "embed" 6 | 7 | //go:embed * 8 | var FS embed.FS 9 | 10 | /* 11 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 12 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 13 | 14 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 15 | to best match the locale in the context. The YAML is expected to be in the following format: 16 | 17 | stringKey: 18 | default: Localized 19 | en: Localized 20 | en-GB: Localised 21 | fr: Localisée 22 | 23 | If a default is not provided, English (en) is used as the fallback language. 24 | String keys and locale names are case insensitive. 25 | */ 26 | -------------------------------------------------------------------------------- /codegen/bundle/service.txt: -------------------------------------------------------------------------------- 1 | package {{ .PackagePathSuffix }} 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | "time" 7 | 8 | "github.com/microbus-io/fabric/errors" 9 | 10 | "{{ .PackageDir }}/intermediate" 11 | "{{ .PackageDir }}/{{ .PackageDirSuffix }}api" 12 | ) 13 | 14 | var ( 15 | _ context.Context 16 | _ *http.Request 17 | _ time.Duration 18 | _ *errors.TracedError 19 | _ *{{ .PackagePathSuffix }}api.Client 20 | ) 21 | 22 | /* 23 | Service implements the {{ .General.Host }} microservice. 24 | {{- if .General.Description }} 25 | 26 | {{ .General.Description }} 27 | {{- end }} 28 | */ 29 | type Service struct { 30 | *intermediate.Intermediate // DO NOT REMOVE 31 | 32 | // TO{{/**/}}DO: Define microservice state variables 33 | } 34 | 35 | // OnStartup is called when the microservice is started up. 36 | func (svc *Service) OnStartup(ctx context.Context) (err error) { 37 | // TO{{/**/}}DO: Implement OnStartup 38 | return nil 39 | } 40 | 41 | // OnShutdown is called when the microservice is shut down. 42 | func (svc *Service) OnShutdown(ctx context.Context) (err error) { 43 | // TO{{/**/}}DO: Implement OnShutdown 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /codegen/bundle/version-gen.txt: -------------------------------------------------------------------------------- 1 | // Code generated by Microbus. DO NOT EDIT. 2 | 3 | package {{ .PackagePathSuffix }} 4 | 5 | const Version = {{ .Version }} 6 | const SourceCodeSHA256 = "{{ .SHA256 }}" 7 | const Timestamp = "{{ .Timestamp }}" 8 | 9 | /* { 10 | "ver": {{ .Version }}, 11 | "sha256": "{{ .SHA256 }}", 12 | "ts": "{{ .Timestamp }}" 13 | } */ 14 | -------------------------------------------------------------------------------- /codegen/bundle/version-gen_test.txt: -------------------------------------------------------------------------------- 1 | // Code generated by Microbus. DO NOT EDIT. 2 | 3 | package {{ .PackagePathSuffix }} 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | 9 | "github.com/microbus-io/fabric/utils" 10 | "github.com/microbus-io/testarossa" 11 | ) 12 | 13 | func Test{{ CapitalizeIdentifier .PackagePathSuffix }}_Versioning(t *testing.T) { 14 | t.Parallel() 15 | tt := testarossa.For(t) 16 | 17 | hash, err := utils.SourceCodeSHA256(".") 18 | if tt.NoError(err) { 19 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 20 | } 21 | buf, err := os.ReadFile("version-gen.go") 22 | if tt.NoError(err) { 23 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /codegen/spec/common.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package spec 18 | 19 | import ( 20 | "strings" 21 | ) 22 | 23 | // conformDesc cleans up the description by removing back-quotes and extra spaces and setting a default if empty. 24 | func conformDesc(desc string, ifEmpty string) string { 25 | desc = strings.TrimSpace(desc) 26 | if desc == "" { 27 | desc = ifEmpty 28 | } 29 | desc = strings.ReplaceAll(desc, "`", "'") 30 | split := strings.Split(desc, "\n") 31 | for i := range split { 32 | split[i] = strings.TrimRight(split[i], " \r\t") 33 | } 34 | return strings.Join(split, "\n") 35 | } 36 | -------------------------------------------------------------------------------- /codegen/spec/general_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package spec 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/microbus-io/testarossa" 23 | "gopkg.in/yaml.v3" 24 | ) 25 | 26 | func TestSpec_General(t *testing.T) { 27 | t.Parallel() 28 | tt := testarossa.For(t) 29 | 30 | var gen General 31 | 32 | err := yaml.Unmarshal([]byte(` 33 | host: super.service 34 | description: foo 35 | `), &gen) 36 | tt.NoError(err) 37 | 38 | err = yaml.Unmarshal([]byte(` 39 | host: $uper.$ervice 40 | description: foo 41 | `), &gen) 42 | tt.Contains(err, "invalid host") 43 | 44 | err = yaml.Unmarshal([]byte(` 45 | host: 46 | description: foo 47 | `), &gen) 48 | tt.Error(err, "invalid host") 49 | 50 | err = yaml.Unmarshal([]byte(` 51 | description: foo 52 | `), &gen) 53 | tt.Error(err, "invalid host") 54 | } 55 | -------------------------------------------------------------------------------- /codegen/spec/type.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package spec 18 | 19 | import "strings" 20 | 21 | // Type is a complex type used in a function. 22 | type Type struct { 23 | Name string 24 | Exists bool 25 | PackagePath string 26 | } 27 | 28 | // PackagePathSuffix returns only the last portion of the full package path. 29 | func (t *Type) PackagePathSuffix() string { 30 | p := strings.LastIndex(t.PackagePath, "/") 31 | if p < 0 { 32 | return t.PackagePath 33 | } 34 | return t.PackagePath[p+1:] 35 | } 36 | -------------------------------------------------------------------------------- /codegen/spec/version.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package spec 18 | 19 | import ( 20 | "path/filepath" 21 | ) 22 | 23 | // Version keeps the versioning information of the code. 24 | type Version struct { 25 | PackagePath string 26 | Version int `json:"ver"` 27 | SHA256 string `json:"sha256"` 28 | Timestamp string `json:"ts"` 29 | } 30 | 31 | // PackagePathSuffix returns only the last portion of the full package path. 32 | func (v *Version) PackagePathSuffix() string { 33 | return filepath.Base(v.PackagePath) 34 | } 35 | -------------------------------------------------------------------------------- /codegen/tester/app/tester/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/codegen/tester" 28 | ) 29 | 30 | // main runs an app containing only the codegen.test service. 31 | func main() { 32 | app := application.New() 33 | app.Add(tester.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /codegen/tester/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package tester 20 | -------------------------------------------------------------------------------- /codegen/tester/resources/3.txt: -------------------------------------------------------------------------------- 1 | 333 -------------------------------------------------------------------------------- /codegen/tester/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /codegen/tester/resources/static/1.txt: -------------------------------------------------------------------------------- 1 | 111 -------------------------------------------------------------------------------- /codegen/tester/resources/static/sub/2.txt: -------------------------------------------------------------------------------- 1 | 222 -------------------------------------------------------------------------------- /codegen/tester/resources/strings.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2025 Microbus LLC and various contributors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | hello: 17 | en: Hello 18 | fr: Bonjour 19 | es: Hola 20 | it: Salve 21 | de: Guten Tag 22 | pt: Olá 23 | da: Goddag 24 | nl: Goedendag 25 | pl: Dzień dobry 26 | no: God dag 27 | tr: Merhaba 28 | sv: God dag 29 | -------------------------------------------------------------------------------- /codegen/tester/testerapi/xycoord.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testerapi 18 | 19 | // XYCoord is a non-primitive type holding X,Y coordinates. 20 | type XYCoord struct { 21 | X float64 `json:"x,omitzero"` 22 | Y float64 `json:"y,omitzero"` 23 | } 24 | -------------------------------------------------------------------------------- /codegen/tester/testerapi/xyline.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testerapi 18 | 19 | // XYLine is a non-primitive type with a nested non-primitive type. 20 | type XYLine struct { 21 | Start XYCoord `json:"start,omitzero"` 22 | End XYCoord `json:"end,omitzero"` 23 | } 24 | -------------------------------------------------------------------------------- /codegen/tester/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package tester 20 | 21 | const Version = 161 22 | const SourceCodeSHA256 = "09755e3973f3a6539c3b2626b03292970946d8c61339e5ba95d60ef4ed6c9ed9" 23 | const Timestamp = "2025-06-08T01:50:02.278975Z" 24 | 25 | /* { 26 | "ver": 161, 27 | "sha256": "09755e3973f3a6539c3b2626b03292970946d8c61339e5ba95d60ef4ed6c9ed9", 28 | "ts": "2025-06-08T01:50:02.278975Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /codegen/tester/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package tester 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestTester_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /connector/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package connector implements the base class of all microservices. 18 | package connector 19 | -------------------------------------------------------------------------------- /connector/testdata/res.html: -------------------------------------------------------------------------------- 1 | {{ . }} 2 | -------------------------------------------------------------------------------- /connector/testdata/res.txt: -------------------------------------------------------------------------------- 1 | {{ . }} 2 | -------------------------------------------------------------------------------- /connector/testdata/strings.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | hello: 3 | en: Hello 4 | en-AU: G'day 5 | it: Ciao 6 | -------------------------------------------------------------------------------- /copyright.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-yyyy Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/copyrighter 18 | // - testdata/* 19 | // - .* 20 | 21 | package fabric 22 | 23 | import _ "github.com/microbus-io/copyrighter/i" 24 | -------------------------------------------------------------------------------- /coreservices/configurator/app/configurator/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/configurator" 28 | ) 29 | 30 | // main runs an app containing only the configurator.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(configurator.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/configurator/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package configurator 20 | -------------------------------------------------------------------------------- /coreservices/configurator/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/configurator/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package configurator 20 | 21 | const Version = 221 22 | const SourceCodeSHA256 = "140eb5cc778ae1d93b69fe4e1364afb851429f6e3ec501f3cf9a0df7db516d36" 23 | const Timestamp = "2025-06-08T01:35:59.147069Z" 24 | 25 | /* { 26 | "ver": 221, 27 | "sha256": "140eb5cc778ae1d93b69fe4e1364afb851429f6e3ec501f3cf9a0df7db516d36", 28 | "ts": "2025-06-08T01:35:59.147069Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/configurator/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package configurator 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestConfigurator_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/control/app/control/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/control" 28 | ) 29 | 30 | // main runs an app containing only the control.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(control.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/control/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package control 20 | -------------------------------------------------------------------------------- /coreservices/control/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/control/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package control 20 | 21 | const Version = 202 22 | const SourceCodeSHA256 = "7de666d76aa5da2f0c281b4f7e21d3b40dcc6a508f048f91749a83f9c24173b0" 23 | const Timestamp = "2025-06-08T01:35:59.258622Z" 24 | 25 | /* { 26 | "ver": 202, 27 | "sha256": "7de666d76aa5da2f0c281b4f7e21d3b40dcc6a508f048f91749a83f9c24173b0", 28 | "ts": "2025-06-08T01:35:59.258622Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/control/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package control 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestControl_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/httpegress/app/httpegress/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/httpegress" 28 | ) 29 | 30 | // main runs an app containing only the http.egress.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(httpegress.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/httpegress/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package httpegress 20 | -------------------------------------------------------------------------------- /coreservices/httpegress/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/httpegress/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package httpegress 20 | 21 | const Version = 125 22 | const SourceCodeSHA256 = "7d1fe0ed2d97779f5cb9b2795cee07ee369a041a5fa911bca27f45d77aac8643" 23 | const Timestamp = "2025-06-08T01:35:59.360275Z" 24 | 25 | /* { 26 | "ver": 125, 27 | "sha256": "7d1fe0ed2d97779f5cb9b2795cee07ee369a041a5fa911bca27f45d77aac8643", 28 | "ts": "2025-06-08T01:35:59.360275Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/httpegress/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package httpegress 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestHttpegress_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/httpingress/app/httpingress/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/httpingress" 28 | ) 29 | 30 | // main runs an app containing only the http.ingress.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(httpingress.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/httpingress/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package httpingress 20 | -------------------------------------------------------------------------------- /coreservices/httpingress/logwriter.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package httpingress 18 | 19 | import ( 20 | "log" 21 | "strings" 22 | ) 23 | 24 | // logWriter captures logs generated by the HTTP servers and directs them to the service's logger. 25 | type logWriter struct { 26 | svc *Service 27 | } 28 | 29 | // Write sends the output to the service's logger. 30 | func (lw *logWriter) Write(p []byte) (n int, err error) { 31 | msg := string(p) 32 | if !strings.Contains(msg, "TLS handshake error") { 33 | lw.svc.LogError(lw.svc.Lifetime(), msg) 34 | } 35 | return len(p), nil 36 | } 37 | 38 | // newHTTPLogger creates a logger that redirects output to the service's logger. 39 | func newHTTPLogger(svc *Service) *log.Logger { 40 | return log.New(&logWriter{svc}, "", 0) 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/blockedpaths.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "net/http" 21 | 22 | "github.com/microbus-io/fabric/connector" 23 | "github.com/microbus-io/fabric/errors" 24 | ) 25 | 26 | // BlockedPaths returns a middleware that returns a 404 error for requests with paths matching the predicate. 27 | // The path passed to the matcher is the full path of the URL, without query arguments. 28 | func BlockedPaths(isBlocked func(path string) bool) Middleware { 29 | return func(next connector.HTTPHandler) connector.HTTPHandler { 30 | notFound := errors.New("", http.StatusNotFound) 31 | return func(w http.ResponseWriter, r *http.Request) error { 32 | if isBlocked(r.URL.Path) { 33 | w.WriteHeader(http.StatusNotFound) 34 | return notFound 35 | } 36 | return next(w, r) // No trace 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/cachecontrol.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "net/http" 21 | 22 | "github.com/microbus-io/fabric/connector" 23 | ) 24 | 25 | // CacheControl returns a middleware that sets the Cache-Control header if not otherwise specified. 26 | func CacheControl(defaultValue string) Middleware { 27 | return func(next connector.HTTPHandler) connector.HTTPHandler { 28 | return func(w http.ResponseWriter, r *http.Request) (err error) { 29 | err = next(w, r) 30 | if w.Header().Get("Cache-Control") == "" { 31 | w.Header().Set("Cache-Control", defaultValue) 32 | } 33 | return err // No trace 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/charsetutf8.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "net/http" 21 | "strings" 22 | 23 | "github.com/microbus-io/fabric/connector" 24 | ) 25 | 26 | // CharsetUTF8 returns a middleware that augments the Content-Type header of text/* and application/json with the UTF-8 charset. 27 | func CharsetUTF8() Middleware { 28 | return func(next connector.HTTPHandler) connector.HTTPHandler { 29 | return func(w http.ResponseWriter, r *http.Request) (err error) { 30 | err = next(w, r) 31 | contentType := strings.ToLower(w.Header().Get("Content-Type")) 32 | if contentType == "application/json" || 33 | (strings.HasPrefix(contentType, "text/") && !strings.Contains(contentType, ";")) { 34 | w.Header().Set("Content-Type", w.Header().Get("Content-Type")+"; charset=utf-8") 35 | } 36 | return err // No trace 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/defaultfavicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/coreservices/httpingress/middleware/defaultfavicon.ico -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/group.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "net/http" 21 | 22 | "github.com/microbus-io/fabric/connector" 23 | ) 24 | 25 | // Group returns a middleware that nested middleware together and is often used in conjunction 26 | // with the `OnRoute` middleware to apply a group of middleware to a specific route. 27 | func Group(nested ...Middleware) Middleware { 28 | return func(next connector.HTTPHandler) connector.HTTPHandler { 29 | handler := next 30 | for n := len(nested) - 1; n >= 0; n-- { 31 | handler = nested[n](handler) 32 | } 33 | return func(w http.ResponseWriter, r *http.Request) (err error) { 34 | return handler(w, r) // No trace 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/internalheaders.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "net/http" 21 | "strings" 22 | 23 | "github.com/microbus-io/fabric/connector" 24 | "github.com/microbus-io/fabric/frame" 25 | ) 26 | 27 | // InternalHeaders returns a middleware that filters internal headers from entering or exiting. 28 | func InternalHeaders() Middleware { 29 | return func(next connector.HTTPHandler) connector.HTTPHandler { 30 | return func(w http.ResponseWriter, r *http.Request) (err error) { 31 | // Do not accept internal headers 32 | for h := range r.Header { 33 | if strings.HasPrefix(h, frame.HeaderPrefix) || h == "Traceparent" || h == "Tracestate" { 34 | r.Header.Del(h) 35 | } 36 | } 37 | err = next(w, r) 38 | // Do not leak internal headers 39 | for h := range w.Header() { 40 | if strings.HasPrefix(h, frame.HeaderPrefix) || h == "Traceparent" || h == "Tracestate" { 41 | w.Header().Del(h) 42 | } 43 | } 44 | return err // No trace 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/noop.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "github.com/microbus-io/fabric/connector" 21 | ) 22 | 23 | // NoOp returns a middleware that delegates to the next middleware in the chain without taking any action. 24 | // It can be used to mark a position in the chain. 25 | func NoOp() Middleware { 26 | return func(next connector.HTTPHandler) connector.HTTPHandler { 27 | return next 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/rootpath.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "net/http" 21 | "strings" 22 | 23 | "github.com/microbus-io/fabric/connector" 24 | ) 25 | 26 | // RootPath returns a middleware that rewrites the root path "/" with one that can be routed to such as "/root". 27 | func RootPath(rootPath string) Middleware { 28 | if !strings.HasPrefix(rootPath, "/") { 29 | rootPath = "/" + rootPath 30 | } 31 | return func(next connector.HTTPHandler) connector.HTTPHandler { 32 | return func(w http.ResponseWriter, r *http.Request) (err error) { 33 | if r.URL.Path == "/" { 34 | r.URL.Path = rootPath 35 | } 36 | return next(w, r) // No trace 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/httpingress/middleware/secureredirect.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package middleware 18 | 19 | import ( 20 | "net/http" 21 | "strings" 22 | 23 | "github.com/microbus-io/fabric/connector" 24 | ) 25 | 26 | // SecureRedirect returns a middleware that redirects requests from HTTP port :80 to HTTPS port :443, if appropriate. 27 | func SecureRedirect(isSecurePort443 func() bool) Middleware { 28 | return func(next connector.HTTPHandler) connector.HTTPHandler { 29 | return func(w http.ResponseWriter, r *http.Request) (err error) { 30 | if r.TLS == nil && r.Method == "GET" && r.URL.Port() == "80" && isSecurePort443() { 31 | u := *r.URL 32 | u.Scheme = "https" 33 | u.Host, _, _ = strings.Cut(u.Host, ":") 34 | s := u.String() 35 | http.Redirect(w, r, s, http.StatusTemporaryRedirect) 36 | return nil 37 | } 38 | return next(w, r) // No trace 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/httpingress/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/httpingress/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package httpingress 20 | 21 | const Version = 325 22 | const SourceCodeSHA256 = "f2d6b5d9bd9d74e7001222341a85a9af25bab8b803d43ac3d3a351ccc91770b0" 23 | const Timestamp = "2025-06-08T03:22:06.747172Z" 24 | 25 | /* { 26 | "ver": 325, 27 | "sha256": "f2d6b5d9bd9d74e7001222341a85a9af25bab8b803d43ac3d3a351ccc91770b0", 28 | "ts": "2025-06-08T03:22:06.747172Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/httpingress/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package httpingress 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestHttpingress_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/metrics/app/metrics/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/metrics" 28 | ) 29 | 30 | // main runs an app containing only the metrics.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(metrics.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/metrics/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package metrics 20 | -------------------------------------------------------------------------------- /coreservices/metrics/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/metrics/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package metrics 20 | 21 | const Version = 176 22 | const SourceCodeSHA256 = "91c79d78e5dcc4e77e9ec94d31d7037cf6dfda25ba65f7132247147c343a9294" 23 | const Timestamp = "2025-06-08T01:35:59.57056Z" 24 | 25 | /* { 26 | "ver": 176, 27 | "sha256": "91c79d78e5dcc4e77e9ec94d31d7037cf6dfda25ba65f7132247147c343a9294", 28 | "ts": "2025-06-08T01:35:59.57056Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/metrics/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package metrics 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestMetrics_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/openapiportal/app/openapiportal/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/openapiportal" 28 | ) 29 | 30 | // main runs an app containing only the openapiportal.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(openapiportal.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/openapiportal/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package openapiportal 20 | -------------------------------------------------------------------------------- /coreservices/openapiportal/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/openapiportal/resources/list.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | 26 | 27 | 28 |

OpenAPI:{{ .Port }}

29 | {{ range .Infos }} 30 |

31 |

{{ .Host }}

32 | {{ .Description }} 33 |

34 | {{ end }} 35 | {{ if eq (len .Infos) 0 }}No OpenAPI endpoints{{ end }} 36 | 37 | -------------------------------------------------------------------------------- /coreservices/openapiportal/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package openapiportal 20 | 21 | const Version = 134 22 | const SourceCodeSHA256 = "34ade4c8a809c658ee4b9f3083701de9c200163a2dcf9af9a2f327beedff052a" 23 | const Timestamp = "2025-06-08T01:35:59.675675Z" 24 | 25 | /* { 26 | "ver": 134, 27 | "sha256": "34ade4c8a809c658ee4b9f3083701de9c200163a2dcf9af9a2f327beedff052a", 28 | "ts": "2025-06-08T01:35:59.675675Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/openapiportal/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package openapiportal 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestOpenapiportal_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/smtpingress/app/smtpingress/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/smtpingress" 28 | ) 29 | 30 | // main runs an app containing only the smtp.ingress.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(smtpingress.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/smtpingress/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package smtpingress 20 | -------------------------------------------------------------------------------- /coreservices/smtpingress/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/smtpingress/smtpingressapi/email.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package smtpingressapi 18 | 19 | import "github.com/mnako/letters" 20 | 21 | // Email is a message received by the email server, then parsed. 22 | type Email = letters.Email 23 | -------------------------------------------------------------------------------- /coreservices/smtpingress/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package smtpingress 20 | 21 | const Version = 155 22 | const SourceCodeSHA256 = "7f33b1921cbd63d969274aaf69431e147e5ca5a97df01f9cb095b2976947843e" 23 | const Timestamp = "2025-06-08T01:35:59.784319Z" 24 | 25 | /* { 26 | "ver": 155, 27 | "sha256": "7f33b1921cbd63d969274aaf69431e147e5ca5a97df01f9cb095b2976947843e", 28 | "ts": "2025-06-08T01:35:59.784319Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/smtpingress/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package smtpingress 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestSmtpingress_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coreservices/tokenissuer/app/authtokenissuer/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/tokenissuer" 28 | ) 29 | 30 | // main runs an app containing only the tokenissuer.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(tokenissuer.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/tokenissuer/app/tokenissuer/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/coreservices/tokenissuer" 28 | ) 29 | 30 | // main runs an app containing only the tokenissuer.core service. 31 | func main() { 32 | app := application.New() 33 | app.Add(tokenissuer.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coreservices/tokenissuer/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package tokenissuer 20 | -------------------------------------------------------------------------------- /coreservices/tokenissuer/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /coreservices/tokenissuer/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package tokenissuer 20 | 21 | const Version = 80 22 | const SourceCodeSHA256 = "5299601b3de253c679cd907df317dc9e9b95c2e80691d07e8e45f517647d0b23" 23 | const Timestamp = "2025-06-08T01:35:59.890181Z" 24 | 25 | /* { 26 | "ver": 80, 27 | "sha256": "5299601b3de253c679cd907df317dc9e9b95c2e80691d07e8e45f517647d0b23", 28 | "ts": "2025-06-08T01:35:59.890181Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /coreservices/tokenissuer/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package tokenissuer 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestTokenissuer_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /dlru/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package dlru implements an LRU cache that is distributed among the peers of a microservice. 18 | package dlru 19 | -------------------------------------------------------------------------------- /docs/blocks/connectivity-liveness-test.md: -------------------------------------------------------------------------------- 1 | # Connectivity Liveness Test 2 | 3 | In `Microbus`, each microservice uses a single bi-directional [persistent connection](../blocks/multiplexed.md) for both incoming and outgoing messages. Consequently, that connection is the single source of truth of its liveness. If the connection drops, the microservice can no longer send messages to other microservices. In addition, once the messaging bus detects the failed connection, it deletes the microservice's subscriptions and no longer delivers any messages to it. Messages will be delivered to the microservice's replicas instead. 4 | 5 | In rare situations, if the messaging bus doesn't realize that a connection dropped, it might still attempt to deliver messages to the disconnected microservice. These messages will be lost and the upstream microservice will receive an [ack timeout](../blocks/ack-or-fail.md). The situation will rectify itself when the messaging bus realizes that the downstream microservice is not responding to pings, or when the microservice reconnects. 6 | 7 | Microservices are responsible for establishing and maintaining the connection to the messaging bus. When a connection drops, they do their best to reconnect. 8 | -------------------------------------------------------------------------------- /docs/blocks/discovery.md: -------------------------------------------------------------------------------- 1 | # Dynamic Service Discovery 2 | 3 | In traditional microservice architectures, microservices are implemented as web servers. Upstream clients who wish to make a request to a downstream microservice must know its location (IP address and port). This is further complicated when multiple replicas of the downstream microservice exist and load balancing is added to the mix. A typical solution is to have the upstream client contact a service discovery or DNS for the location (IP and port) of the downstream microservice, before making (pushing) its request. In this setup, the service discovery is a separate system from the transport layer (HTTP) and inconsistencies may occur if it is not in sync with the current state of any of the microservices. 4 | 5 | In `Microbus`, microservices are not web servers. Instead, they are lightweight goroutines that pull (consume) messages off [carefully-crafted subscriptions](../blocks/unicast.md#notes-on-subscription-subjects) from a messaging bus. A microservice's subscriptions on the messaging bus are how it is discovered by clients (publishers). When a subscription is established, such as when the microservice starts up, the microservice becomes immediately discoverable. When the subscription is closed, such as when the microservice shuts down, the microservice is not longer discoverable. The messaging bus is in effect the service discovery. An external service discovery system is not required. 6 | 7 | 8 |

9 | -------------------------------------------------------------------------------- /docs/blocks/distrib-tracing-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/blocks/distrib-tracing-1.png -------------------------------------------------------------------------------- /docs/blocks/distrib-tracing-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/blocks/distrib-tracing-2.png -------------------------------------------------------------------------------- /docs/blocks/embedded-res.md: -------------------------------------------------------------------------------- 1 | # Embedded Resources 2 | 3 | The `Connector` construct provides a read-only file system (`FS`) from which microservices can read static resources during runtime. The convenience methods `ReadResFile`, `ReadResTextFile`, `ServeResFile`, `ExecuteResTemplate` and `LoadResString` provide access to the file system. 4 | 5 | The `Connector`'s file system is initialized to the current working directory. Two microservices sharing the same app will therefore share the same working directory and their file systems will overlap. The `FS` can be set using the `Connector`'s `SetResFS` before the microservice is started. 6 | 7 | In the more common case, when a microservice is created using the code generator, the file system is initialized to an [embedded `FS`](https://pkg.go.dev/embed) pointing to the `resources` directory in the [source directory of the microservice](../blocks/uniform-code.md). Any source files placed in that directory are automatically made available via the `FS`. 8 | -------------------------------------------------------------------------------- /docs/blocks/graceful-shutdown.md: -------------------------------------------------------------------------------- 1 | # Graceful Shutdown 2 | 3 | Microservices are designed to run on cloud hardware that often shuts down at unpredictable times. When a microservice receives the signal to terminate, it first stops accepting new operations and attempts to end all pending operations gracefully. 4 | 5 | Graceful shutdown process: 6 | * Disable tickers so new iterations do not run 7 | * Stop accepting new requests 8 | * Wait 8 seconds for running tickers, pending requests and goroutines to end naturally 9 | * Cancel the lifetime `context.Context` of the microservice 10 | * Wait 4 more seconds for running tickers and pending requests, and goroutines to quit 11 | * Close the connection to the bus 12 | * Exit 13 | 14 | In order for goroutines to gracefully shut down, it is important to launch them using the `Connector`'s `Go` method rather than using the standard `go` keyword. When launched with `Go`, the goroutines are given the `context.Context` that gets canceled during termination. 15 | -------------------------------------------------------------------------------- /docs/blocks/i18n.md: -------------------------------------------------------------------------------- 1 | # Internationalization 2 | 3 | The `Connector`'s `LoadResString` method loads and localizes strings stored in a [static resource](../blocks/embedded-res.md) named `strings.yaml`. `LoadResString` extracts the request's locale from the `Accept-Language` header embedded in the context's [frame](../structure/frame.md), and returns the string in the language best matching it. 4 | 5 | ```go 6 | func (svc *Service) Localization(w http.ResponseWriter, r *http.Request) (err error) { 7 | ctx := r.Context() 8 | localizedStr, _ := svc.LoadResString(ctx, "stringKey") 9 | w.Write([]byte(localizedStr)) 10 | return nil 11 | } 12 | ``` 13 | 14 | `strings.yaml` is expected to have the following format: 15 | 16 | ```yaml 17 | stringKey: 18 | default: Localized 19 | en: Localized 20 | en-GB: Localised 21 | fr: Localisée 22 | ``` 23 | 24 | If a default is not provided, English (en) is used as the fallback language. 25 | String keys and locale names are case insensitive. 26 | -------------------------------------------------------------------------------- /docs/blocks/lb.md: -------------------------------------------------------------------------------- 1 | # Load Balancing 2 | 3 | Microservices in `Microbus` are lightweight goroutines that pull (consume) messages off a messaging bus, in which a queue is maintained for each endpoint of each microservice. Replicas of the same microservice subscribe to the same queues and consume messages as they are published. Load balancing is achieved by virtue of the bus dispatching messages from the queue to only one random consumer at a time. A separate load balancer is therefore not required. 4 | 5 | 6 |

7 | 8 | `Microbus` also allows for [multicast](../blocks/multicast.md) subscriptions in which all replicas receive all messages. 9 | 10 | 11 |

12 | 13 | When using the `Connector`'s `Subscribe` method directly, multicasting can be enabled via the `sub.NoQueue()` option. 14 | 15 | When using [`service.yaml`](../tech/service-yaml.md) and the [code generator](../blocks/codegen.md), the `queue: none` property is used to indicate a multicast subscription. 16 | 17 | [Events](../blocks/events.md) are by definition multicast. 18 | -------------------------------------------------------------------------------- /docs/blocks/logging.md: -------------------------------------------------------------------------------- 1 | # Structured Logging 2 | 3 | Logging is one of the pillars of observability alongside [distributed tracing](../blocks/distrib-tracing.md) and [metrics](../blocks/metrics.md). `Microbus` uses Go's standard `log/slog` for logging with output directed to `stderr`. 4 | 5 | Logs are printed in human-friendly format in the `LOCAL` and `TESTING` [deployment environments](../tech/deployments.md) and in JSON in `PROD` and `LAB`. 6 | 7 | Logs are automatically enriched with the microservice's hostname, version number and ID, as well by the distributed trace ID, if applicable. 8 | 9 | In addition, logs are metered on a per-message basis to make them visible in Grafana. For this reason, the message part should be a fixed string, and all variable parts added as arguments. 10 | 11 | The `Connector` supports 4 methods for logging at different severity levels: `LogDebug`, `LogInfo`, `LogWarn` and `LogError`. Debug logs are ignored unless the `MICROBUS_LOG_DEBUG` [environment variable](../tech/envars.md) is set. 12 | 13 | Example: 14 | 15 | ```go 16 | c.LogInfo(ctx, "Fixed message", 17 | "key1", "value", 18 | "key2", 1234, 19 | ) 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/blocks/metrics-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/blocks/metrics-1.png -------------------------------------------------------------------------------- /docs/blocks/multiplexed.md: -------------------------------------------------------------------------------- 1 | # Persistent Multiplexed Connections 2 | 3 | A persistent multiplexed connection is a TCP connection that is kept open and allows bi-directional streaming exchange of requests and responses at any time. Unlike HTTP/1.1, there is no restriction to have only one request and one response for the lifetime of the connection. A multiplexed connection can transport multiple requests and responses at the same time, interwoven on the timeline, and out of order. HTTP/2 and gRPC are a multiplexed connection. 4 | 5 | Three concurrent HTTP/1.1 requests utilize three TCP connections: 6 | 7 | 8 |

9 | 10 | A multiplexed connection on the other hand can serve the three requests on a single TCP connection: 11 | 12 | 13 |

14 | 15 | The benefits of a persistent multiplexed connection are: 16 | * A single multiplexed connection is more memory efficient when compared to multiple HTTP/1.1 connections open concurrently 17 | * There is almost no risk of running out of the approx 50,000 ephemeral ports needed to maintain a TCP connection, allowing a practically-unlimited number of concurrent requests 18 | * The overhead of establishing the connection, especially if it is a secure connection, is incurred only once 19 | * A connection that is persistent reduces churn in the network routing table, lending to a more stable networking topology 20 | -------------------------------------------------------------------------------- /docs/howto/first-service-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/howto/first-service-1.png -------------------------------------------------------------------------------- /docs/howto/quick-start-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/howto/quick-start-1.png -------------------------------------------------------------------------------- /docs/howto/self-explore.md: -------------------------------------------------------------------------------- 1 | # Explore on Your Own 2 | 3 | * Start NATS in debug and verbose modes `./nats-server -D -V`, run unit tests individually and look at the messages going over the bus 4 | * Modify `main/config.yaml` and witness the impact on the `hello.example` microservice. You'll have to restart the app for the configurator to pick up the new values 5 | * Add an endpoint `/increment` to the `calculator.example` microservice that returns the value of an input integer x plus 1 6 | * Add an endpoint `/calculate` to the `calculator.example` microservice that operates on decimal numbers, not just integers. Can you make `hello.example/calculator` work with decimals too? 7 | * Create your own microservice from scratch and add it to `main/main.go` 8 | * Put a breakpoint in any of the microservices of the example application and try debugging 9 | * Add a `/cache-delete` endpoint to the `messaging.example` 10 | * Create a second event sink microservice (name it differently though) and block registrations based on a configurable exclusion list 11 | -------------------------------------------------------------------------------- /docs/structure/cfg.md: -------------------------------------------------------------------------------- 1 | # Package `cfg` 2 | 3 | The `cfg` package is used to enable the options pattern in `Connector.DefineConfig`. This pattern is used in Go for expressing optional arguments. This package defines the various `Option`s as well as their collector `Config` which is not used directly but rather applies and collects the list of `Option`s behind the scenes. 4 | 5 | For example: 6 | 7 | ```go 8 | con.DefineConfig("Database", cfg.Validation("url"), cfg.Secret()) 9 | ``` 10 | 11 | The following options are supported: 12 | 13 | * `cfg.DefaultValue` specifies a default value for the property when one is not provided by the configurator 14 | * `cfg.Validation` uses a pattern to validate values before they are set 15 | * `str` - Plain text, no validation 16 | * `str ^[a-zA-Z0-9]+$` - Text with regexp validation 17 | * `bool` - Must be `true` or `false` 18 | * `int` - An integer, no validation 19 | * `int [0,60]` - An integer in range 20 | * `float` - A decimal number, no validation 21 | * `float [0.0,1.0)` - A decimal number in range 22 | * `dur` - A duration such as `7h3m45s500ms300us100ns` 23 | * `dur (0s,24h]` - A duration in range 24 | * `set Red|Green|Blue` - A set of explicit options separated by `|` 25 | * `url` - A URL 26 | * `email` - An email address, either `Joe ` or just `joe@example.com` 27 | * `json` - A valid JSON string 28 | * `cfg.Secret` indicates that the value of this property is a secret and should not be logged 29 | * `cfg.Description` is intended to explain the purpose of the config property and how it will impact the microservice 30 | -------------------------------------------------------------------------------- /docs/structure/codegen.md: -------------------------------------------------------------------------------- 1 | # Package `codegen` 2 | 3 | The `codegen` package implements the [code generation tool](../blocks/codegen.md). 4 | -------------------------------------------------------------------------------- /docs/structure/coreservices-control.md: -------------------------------------------------------------------------------- 1 | # Package `coreservices/control` 2 | 3 | The `control.core` microservice provides no function and in fact will not start. It is the code generated clients in `controlapi` that are the essence of this package. These clients, and in particular the `controlapi.MulticastClient`, provide a programmatic interface to the [control subscriptions](../tech/control-subs.md) that all microservices support. 4 | 5 | For example, to ping and discover all microservices: 6 | 7 | ```go 8 | ch := controlapi.NewMulticastClient(svc).ForHost("all").Ping(ctx) 9 | for r := range ch { 10 | fromHost := frame.Of(r.HTTPResponse).FromHost() 11 | fromID := frame.Of(r.HTTPResponse).FromID() 12 | } 13 | ``` 14 | 15 | Overriding the host of the client via `ForHost` is required because the default host `control.core` does not exist. In the example above, the special hostname `all` is used to address all microservices. 16 | -------------------------------------------------------------------------------- /docs/structure/coreservices-metrics.md: -------------------------------------------------------------------------------- 1 | # Package `coreservices/metrics` 2 | 3 | The metrics core microservice provides a single endpoint that lets [Prometheus](https://prometheus.io) scrape [metrics](../blocks/metrics.md) from all microservices at once. Prometheus pulls metrics from the metrics core microservice, which in turn pulls and aggregates metrics from all microservices it can reach on the messaging bus. 4 | 5 | 6 |

7 | 8 | The endpoint to obtain metrics from the metrics microservice is `https://localhost:8080/metrics.core/collect`. An optional argument `service` can be used to obtain the metrics of an individual service. The `secretkey` argument is mandatory except in local development and testing. It must match the value set for the `SecretKey` configuration property or else the request will be denied. 9 | 10 | Metrics can also be obtained from a microservice directly at `https://localhost:8080/hello.example:888/metrics`. 11 | 12 | The metrics core microservice is unnecessary if metrics are pushed to an OpenTelemetry collector, rather than pulled. 13 | -------------------------------------------------------------------------------- /docs/structure/coreservices-openapiportal.md: -------------------------------------------------------------------------------- 1 | # Package `coreservices/openapiportal` 2 | 3 | All `Microbus` microservices [produce OpenAPI documents](../blocks/openapi.md) describing their endpoints. 4 | The OpenAPI portal core microservice renders an HTML portal page that lists all microservices that have an OpenAPI endpoint on the same port as the request. For example, the portal page at the internal `Microbus` address of `https://openapi:443` finds all microservices with open endpoints on port `:443`. 5 | -------------------------------------------------------------------------------- /docs/structure/coreservices-smtpingress.md: -------------------------------------------------------------------------------- 1 | # Package `coreservices/smtpingress` 2 | 3 | The SMTP ingress microservice listens on port `:25` for incoming email messages. An app can listen to the appropriate event in order to process and act upon the email message. 4 | 5 | Use the following event sink in `service.yaml` to listen to the event: 6 | 7 | ```yaml 8 | sinks: 9 | - signature: OnIncomingEmail(mailMessage *Email) 10 | description: OnIncomingEmail is triggered when a new email message is received. 11 | source: github.com/microbus-io/fabric/coreservices/smtpingress 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/structure/coreservices.md: -------------------------------------------------------------------------------- 1 | # Package `coreservices` 2 | 3 | The `coreservices` package is a collection of microservices that implement common functionality required by most if not all `Microbus` applications. 4 | 5 | * The [configurator](../structure/coreservices-configurator.md) is responsible for delivering configuration values to microservices that define configuration properties. Such microservices will not start if they cannot reach the configurator 6 | * [Control](../structure/coreservices-control.md) is not actually a microservice but rather a stub microservice used to generate a client for the `:888` [control subscriptions](../tech/control-subs.md) 7 | * The [HTTP egress proxy](../structure/coreservices-httpegress.md) relays HTTP requests to non-`Microbus` URLs 8 | * The [HTTP ingress proxy](../structure/coreservices-httpingress.md) bridges the gap between HTTP clients and the microservices running on `Microbus` 9 | * The [metrics](../structure/coreservices-metrics.md) microservice aggregates metrics from all microservices in response to a request from Prometheus 10 | * The [OpenAPI portal](../structure/coreservices-openapiportal.md) microservice renders a catalog of the OpenAPI endpoints of all microservices. 11 | * The [SMTP ingress](../structure/coreservices-smtpingress.md) microservice transforms incoming emails to actionable events 12 | * The [token issuer](../structure/coreservices-tokenissuer.md) microservice issues and validates tokens in the form of JWTs. 13 | -------------------------------------------------------------------------------- /docs/structure/dlru.md: -------------------------------------------------------------------------------- 1 | # Package `dlru` 2 | 3 | The `dlru` package implements a [distributed LRU cache](../blocks/distrib-cache.md) that is shared among all peer replicas of a microservice. The cache uses pub/sub over NATS to communicate and synchronize. 4 | 5 | By default, a DLRU is created and assigned for each microservice and made available using `svc.DistribCache()`. 6 | 7 | ```go 8 | var obj MyObject 9 | ok, err := svc.DistribCache().LoadJSON(ctx, cacheKey, &obj) 10 | if err != nil { 11 | return errors.Trace(err) 12 | } 13 | if !ok { 14 | obj, err = svc.loadObjectFromDatabase(ctx, objKey) 15 | if err != nil { 16 | return errors.Trace(err) 17 | } 18 | err = svc.DistribCache().StoreJSON(ctx, cacheKey, obj) 19 | if err != nil { 20 | return errors.Trace(err) 21 | } 22 | } 23 | ``` 24 | 25 | Additional DLRU caches can be created manually. 26 | The constructor requires a microservice in order to be able to communicate with NATS, and the path of the NATS subscription to use for synchronization among peers. The cache's capacity and TTL can be configured as well. 27 | 28 | ```go 29 | myCache, err := dlru.NewCache(ctx, svc, ":444/my-cache") 30 | if err != nil { 31 | return errors.Trace(err) 32 | } 33 | myCache.SetMaxMemoryMB(5) 34 | myCache.SetMaxAge(time.Hour) 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/structure/env.md: -------------------------------------------------------------------------------- 1 | # Package `env` 2 | 3 | Package `env` manages the loading of environment variables. 4 | Variables are first searched for in an in-memory stack, then in a file `env.yaml` in the current working directory, and finally in the OS. 5 | The in-memory stack provides `Push` and `Pop` operations and is intended for modifying the environment during unit and integration testing. 6 | The YAML file allows the setting of environment variables in a file that can be shared and version-controlled. 7 | -------------------------------------------------------------------------------- /docs/structure/examples-browser.md: -------------------------------------------------------------------------------- 1 | # Package `examples/browser` 2 | 3 | The `browser.example` microservice implement a single endpoints, `/browse` that renders an HTML page with a form that takes in a URL and fetches the source code of the page. This example demonstrates how to use the [HTTP egress core microservice](../structure/coreservices-httpegress.md) as well as how to mock it in tests. 4 | 5 | Visit http://localhost:8080/browser.example/browse to play around with the simple UI. 6 | -------------------------------------------------------------------------------- /docs/structure/examples-directory-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/structure/examples-directory-1.png -------------------------------------------------------------------------------- /docs/structure/examples-directory-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/structure/examples-directory-2.png -------------------------------------------------------------------------------- /docs/structure/examples-events.md: -------------------------------------------------------------------------------- 1 | # Package `examples/eventsource` and Package `examples/eventsink` 2 | 3 | The `eventsource.example` and `eventsink.example` demonstrate how [events reverse the dependency between two microservices](../blocks/events.md). The event source microservice is unaware and independent of the event sink microservice, event though technically it is the initiator of a request to the event sink. Rather, it is the event sink that is aware of and dependent on the event source. 4 | 5 | In this example, the `eventsource.example` mocks a simple user registration microservice that fires events to see if any filtering microservices wish to block the registration. The `eventsink.example` microservice acts as a filter provider for the `eventsource.example` microservice and disallows certain registrations. Other such filter providers may be added in the future without requiring changes to the `eventsource.example`. 6 | 7 | Try the following URLs in order: 8 | 9 | * http://localhost:8080/eventsource.example/register?email=peter@example.com : example.com domain is allowed. 10 | * http://localhost:8080/eventsource.example/register?email=mary@example.com : example.com domain is allowed. 11 | * http://localhost:8080/eventsource.example/register?email=paul@gmail.com : gmail.com domain is disallowed. 12 | * http://localhost:8080/eventsource.example/registered 13 | -------------------------------------------------------------------------------- /docs/structure/examples-hello-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/docs/structure/examples-hello-1.png -------------------------------------------------------------------------------- /docs/structure/examples-helloworld.md: -------------------------------------------------------------------------------- 1 | # Package `examples/helloworld` 2 | 3 | The `helloworld.example` microservice demonstrates the classic minimalist example. 4 | 5 | http://localhost:8080/helloworld.example/hello-world simply prints `Hello, World!`. 6 | 7 | The code looks rather daunting but practically all of it is code generated. The manually-coded pieces are: 8 | 9 | The definition of the service and its single endpoint `HelloWorld` in `service.yaml`: 10 | 11 | ```yaml 12 | general: 13 | host: helloworld.example 14 | description: The HelloWorld microservice demonstrates the classic minimalist example. 15 | 16 | webs: 17 | - signature: HelloWorld() 18 | description: HelloWorld prints the classic greeting. 19 | ``` 20 | 21 | The implementation of the `HelloWorld` endpoint in `service.go`: 22 | 23 | ```go 24 | w.Write([]byte("Hello, World!")) 25 | return nil 26 | ``` 27 | 28 | A test of `TestHelloworld_HelloWorld` in `integration_test.go`: 29 | 30 | ```go 31 | ctx := Context() 32 | HelloWorld_Get(t, ctx, "").BodyContains("Hello, World!") 33 | ``` 34 | 35 | And finally, the addition of the microservce to the app in `main/main.go`. 36 | 37 | ```go 38 | app.Add( 39 | helloworld.NewService(), 40 | ) 41 | ``` 42 | -------------------------------------------------------------------------------- /docs/structure/examples.md: -------------------------------------------------------------------------------- 1 | # Package `examples` 2 | 3 | The `examples` package holds several examples that demonstrate how the `Microbus` framework is used to create microservices. When studying an example, start by looking at the `service.yaml` to get a quick overview of the functionality of the microservice. Then go deep into the code in `service.go`. All files with `-gen` in their name are code generated and can be ignored until you're ready to go deep into the internals of `Microbus`. 4 | 5 | * [HelloWorld](../structure//examples-helloworld.md) demonstrates the classic minimalist example 6 | * [Hello](../structure/examples-hello.md) demonstrates the key capabilities of the framework 7 | * [Calculator](../structure/examples-calculator.md) demonstrates functional handlers 8 | * [Messaging](../structure/examples-messaging.md) demonstrates load-balanced unicast, multicast and direct addressing messaging 9 | * [Event source and sink](../structure/examples-events.md) shows how events can be used to reverse the dependency between two microservices 10 | * [Directory](../structure/examples-directory.md) is an example of a microservice that provides a CRUD API backed by a database 11 | * [Browser](../structure/examples-browser.md) is an example of a microservice that uses the [HTTP egress core microservice](../structure/coreservices-httpegress.md) 12 | * [Login](../structure/examples-login.md) employs authentication and authorization to restrict access to certain endpoints 13 | 14 | In case you missed it, the [quick start guide](../howto/quick-start.md) explains how to setup your system to run the examples. 15 | -------------------------------------------------------------------------------- /docs/structure/openapi.md: -------------------------------------------------------------------------------- 1 | # Package `openapi` 2 | 3 | All `Microbus` microservices [produce OpenAPI documents](../blocks/openapi.md) describing their endpoints. The `openapi` package is an internal package that supports the generation of these documents by: 4 | 5 | * Modeling the OpenAPI document using Go structs to facilitate marshaling it as YAML 6 | * Translating Go primitives to the corresponding OpenAPI types 7 | * Traversing the dependency tree of complex types (structs) using reflection and translating them into the corresponding OpenAPI components 8 | -------------------------------------------------------------------------------- /docs/structure/pub.md: -------------------------------------------------------------------------------- 1 | # Package `pub` 2 | 3 | The `pub` package is used to enable the options pattern in `Connector.Publish`. This pattern is used in Go for expressing optional arguments. This package defines the various `Option`s as well as their collector `Request` which is not used directly but rather applies and collects the list of `Option`s behind the scenes. 4 | 5 | For example: 6 | 7 | ```go 8 | con.Publish( 9 | ctx, 10 | pub.GET("https://another.svc/bar"), 11 | pub.Body("foo"), 12 | ) 13 | ``` 14 | -------------------------------------------------------------------------------- /docs/structure/rand.md: -------------------------------------------------------------------------------- 1 | # Package `rand` 2 | 3 | The `rand` package is a utility that combines `crypto.rand` and `math.rand` for more secure random number generation with reduced performance impact. 4 | -------------------------------------------------------------------------------- /docs/structure/service.md: -------------------------------------------------------------------------------- 1 | # Package `service` 2 | 3 | Package `service` defines various interfaces of a microservice. The [`Connector`](connector.md) implements these interfaces. 4 | -------------------------------------------------------------------------------- /docs/structure/sub.md: -------------------------------------------------------------------------------- 1 | # Package `sub` 2 | 3 | The `sub` package defines the internal `Subscription` struct that facilitates the endpoint subscriptions of the microservice. It transforms the partial path specification in `Connector.Subscribe` to produce a fully-qualified URL. 4 | 5 | | Path specification | Fully-qualified URL | 6 | | - | - | 7 | | (empty) | https://example.host | 8 | | / | https://example.host/ | 9 | | :1080 | https://example.host:1080 | 10 | | :1080/ | https://example.host:1080/ | 11 | | :1080/path | https://example.host:1080/path | 12 | | /path/with/slash | https://example.host:443/path/with/slash | 13 | | path/with/no/slash | https://example.host:443/path/with/no/slash | 14 | | /path/{argument}/or/{suffix+} | https://example.host:443/path/{argument}/or/{suffix+} | 15 | | https://another.host/path | https://another.host:443/path | 16 | | https://another.host:1080/path | https://another.host:1080/path | 17 | 18 | This package also defines various `Option`s that can be applied to the `Subscription` using the options pattern. This pattern is used in Go for expressing optional arguments. 19 | 20 | For example: 21 | 22 | ```go 23 | con.Subscribe("GET", "/path", handler, sub.NoQueue()) 24 | ``` 25 | -------------------------------------------------------------------------------- /docs/structure/trc.md: -------------------------------------------------------------------------------- 1 | # Package `trc` 2 | 3 | The `trc` package supports distributed tracing with OpenTelemetry. It defines various `Option`s that can be applied to the tracing span using the options pattern. This pattern is used in Go for expressing optional arguments. 4 | 5 | For example: 6 | 7 | ```go 8 | con.StartSpan(ctx, "Job", trc.String("name", "my job")) 9 | ``` 10 | -------------------------------------------------------------------------------- /docs/structure/utils.md: -------------------------------------------------------------------------------- 1 | # Package `utils` 2 | 3 | Package `utils` includes various independent utilities. 4 | 5 | `SourceCodeSHA256` reads the content of a source code directory and generates a SHA256 of its relevant content. It is used by the code generator for change detection and automatic versioning. 6 | 7 | `SyncMap` is a thin wrapper over a subset of the operations of the standard `sync.Map`. It introduces generics to make these more type-safe. 8 | -------------------------------------------------------------------------------- /docs/tech/deployments.md: -------------------------------------------------------------------------------- 1 | # Deployments 2 | 3 | `Microbus` recognizes four deployment environments: 4 | 5 | * `PROD` represents a production deployment 6 | * `LAB` represents a fully-functional non-production deployments such as dev integration, testing, staging, etc. 7 | * `LOCAL` represents development on an engineer's local machine 8 | * `TESTING` represents a unit test running a testing application 9 | 10 | The deployment environment impacts certain aspects of the framework such as [structured logging](../blocks/logging.md) and [distributed tracing](../blocks/distrib-tracing.md). 11 | 12 | | |`PROD`|`LAB`|`LOCAL`|`TESTING`| 13 | |--------|----|---|-----|----------| 14 | |Logging level|INFO|DEBUG|DEBUG|DEBUG| 15 | |Logging format|JSON|JSON|Human-friendly|Human-friendly| 16 | |Logging errors|Standard|Standard|Emphasized|Emphasized| 17 | |Distributed tracing|Selective|Everything|Everything|Everything| 18 | |Configurator|Enabled|Enabled|Enabled|Disabled| 19 | |Tickers|Enabled|Enabled|Enabled|Disabled| 20 | |Error output|Redacted|Stack trace|Stack trace|Stack trace| 21 | 22 | The deployment environment is set according to the value of the `MICROBUS_DEPLOYMENT` [environment variable](../tech/envars.md). If not specified, `PROD` is assumed, unless connecting to NATS on `nats://localhost:4222` or `nats://127.0.0.1:4222` in which case `LOCAL` is assumed. 23 | -------------------------------------------------------------------------------- /docs/tech/encapsulation.md: -------------------------------------------------------------------------------- 1 | # Encapsulation Pattern 2 | 3 | `Microbus` employs the principle of information hiding and opts to encapsulate the underlying technologies behind its own simplified interfaces. There are various reasons for this pattern: 4 | 5 | * Providing a cohesive experience to developers 6 | * Enforcing uniformity across all microservices brings familiarity when looking at someone else's code, lowers the learning curve, and ultimately increases velocity 7 | * The underlying technology can be changed with little impact to the microservices 8 | * Oftentimes the underlying technology is more extensive than the basic functionality that is needed by the framework. Encapsulating the underlying API enables exposing only certain functions to the developer 9 | * The framework is in control of when and how the underlying technology is initialized 10 | * The framework is able to seamlessly integrate building blocks together. This will take shape as more building blocks are introduced 11 | * Bugs or CVEs in the underlying technologies are quicker to fix because there is only one source of truth. A bug such as [Log4Shell CVE-2021-44228](https://logging.apache.org/log4j/2.x/security.html) would require no code changes to the microservices, only to the framework 12 | 13 | One example of this pattern is with the configuration of microservices. Rather than leave things up to each individual developer how to fetch config values, the `Connector` defines an interface that encapsulates the underlying implementation. Today, the framework looks for config values in a `config.yaml` file. In the future, it might be extended to fetch configs from a remote location. 14 | -------------------------------------------------------------------------------- /docs/tech/json-vs-protobuf.md: -------------------------------------------------------------------------------- 1 | # JSON vs Protobuf 2 | 3 | `Microbus` uses JSON over HTTP as the default protocol with which input arguments are sent to functional endpoints, and conversely, output arguments are returned from functional endpoints. Albeit not as efficient as [Protobuf](https://protobuf.io), JSON was chosen for several reasons: 4 | 5 | * JSON is fully compatible with JavaScript-based clients such as React applications, making each endpoint easily exposed as a public API 6 | * JSON is the basis for the two common web API styles: [RPC over JSON and REST](../tech/rpc-vs-rest.md) 7 | * JSON is human-readable and more easily debuggable, contributing to engineering velocity 8 | * Like Protobuf, JSON is extensible 9 | * JSON is only about 2x slower than Protobuf, which in most cases is negligible compared to the network latency 10 | -------------------------------------------------------------------------------- /docs/tech/local-dev.md: -------------------------------------------------------------------------------- 1 | # Local Development 2 | 3 | In `Microbus`, microservices are not large memory-gobbling processes but rather compact worker goroutines that ultimately consume messages from a queue. Microservices also don’t listen on ports so there is no potential of a port conflict with other microservices. These two qualities allow `Microbus` to spin up a large multitude of microservices in a single executable, enabling engineers to run and debug an entire application in their IDE. In fact, starting or restarting an application takes only a second or two, allowing engineers to iterate on code change quickly. It is a huge productivity boost. 4 | 5 | Those same qualities also allow `Microbus` to spin a microservice along with all its downstream dependencies inside a single [application for testing](../blocks/integration-testing.md) purposes. Full-blown integration tests can then be run by `go test`, achieving a high-degree of code coverage. 6 | 7 | In addition, the compact footprint of a `Microbus` application also enables the front-end team to run it locally rather than depend on a remote integration environment. 8 | -------------------------------------------------------------------------------- /docs/tech/nats-connection.md: -------------------------------------------------------------------------------- 1 | # NATS Connection Settings 2 | 3 | NATS is the communication medium of microservices and all microservices must first and foremost be connected to NATS in order to send and receive messages. By default, microservices attempt to connect to NATS on `nats://127.0.0.1:4222` using a plain (unsecure) TCP connection. The `MICROBUS_NATS` [environment variable](../tech/envars.md) is used to customize this connection URL. 4 | 5 | NATS supports [various authentication methods](https://docs.nats.io/using-nats/developer/connecting) for connecting to the NATS cluster. The `Microbus` framework is exposing some of these via [environment variables](../tech/envars.md) and certificate files. 6 | 7 | The `MICROBUS_NATS_USER` and `MICROBUS_NATS_PASSWORD` [environment variables](../tech/envars.md), when present, are used to authenticate with simple [username and password](https://docs.nats.io/using-nats/developer/connecting/userpass) credentials. 8 | 9 | The `MICROBUS_NATS_TOKEN` [environment variable](../tech/envars.md), when present, is used to authenticate with an [API token](https://docs.nats.io/using-nats/developer/connecting/token#connecting-with-a-token) credential. 10 | 11 | NATS needs a public certificate and a private key in order to [secure the connection to NATS with TLS](https://docs.nats.io/using-nats/developer/connecting/tls). `Microbus` looks for the certs in the current working directory under the names `cert.pem` and `key.pem`. 12 | 13 | A root certificate authority (CA) certificate may be required by NATS to trust other certificates. `Microbus` looks for the CA certificate file in the current working directory under the name `ca.pem`. 14 | -------------------------------------------------------------------------------- /docs/tech/out-of-scope.md: -------------------------------------------------------------------------------- 1 | # Out of Scope 2 | 3 | `Microbus`'s focus is on building and operating microservices at scale. The following areas are currently out of scope: 4 | 5 | * __User interface__ - `Microbus` is a backend framework. Its link to the front-end are microservice endpoints that respond with JSON to single-page front-end applications, and an OpenAPI document that catalogs those endpoints. It is possible for microservices to generate HTML but `Microbus` provides no tooling in this area. 6 | * __SDLC automation__ - Automating the SDLC of `Microbus` solutions is currently out of scope. 7 | * __Databases__ - The choice of database depends heavily on the use case of the solution. As an enabling technology, `Microbus` takes no sides and does not offer tooling in the areas of data access and processing. 8 | * __AI__ - Artificial intelligence is currently out of scope. 9 | 10 | Some of these areas have room for contributors to step in. Contact us if you want to [get involved](../../README.md#-get-involved). 11 | -------------------------------------------------------------------------------- /env/testdata/env.yaml: -------------------------------------------------------------------------------- 1 | X5981245X: InFile 2 | x5981245x: infile -------------------------------------------------------------------------------- /errors/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package errors replaces the standard Go package, adding the ability to attach a stack trace 19 | and annotations to an error 20 | */ 21 | package errors 22 | -------------------------------------------------------------------------------- /errors/stackframe.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package errors 18 | 19 | import ( 20 | "fmt" 21 | ) 22 | 23 | // StackFrame is a single stack location. 24 | type StackFrame struct { 25 | Function string `json:"function"` 26 | File string `json:"file"` 27 | Line int `json:"line"` 28 | } 29 | 30 | // String returns a string representation of the stack frame. 31 | func (t *StackFrame) String() string { 32 | return fmt.Sprintf("- %s\n %s:%d", t.Function, t.File, t.Line) 33 | } 34 | -------------------------------------------------------------------------------- /examples/browser/app/browser/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/browser" 28 | ) 29 | 30 | // main runs an app containing only the browser.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(browser.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/browser/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package browser 20 | -------------------------------------------------------------------------------- /examples/browser/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/browser/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package browser 20 | 21 | const Version = 108 22 | const SourceCodeSHA256 = "4cafa6831829848e894e205b054830bc5be9804cc973de8d5ffac6eb28087986" 23 | const Timestamp = "2025-06-08T01:35:59.99678Z" 24 | 25 | /* { 26 | "ver": 108, 27 | "sha256": "4cafa6831829848e894e205b054830bc5be9804cc973de8d5ffac6eb28087986", 28 | "ts": "2025-06-08T01:35:59.99678Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/browser/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package browser 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestBrowser_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/calculator/app/calculator/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/calculator" 28 | ) 29 | 30 | // main runs an app containing only the calculator.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(calculator.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/calculator/calculatorapi/point.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package calculatorapi 18 | 19 | // Point is a 2D (X,Y) coordinate. 20 | type Point struct { 21 | X float64 `json:"x,omitzero" jsonschema:"description=X coordinate,example=6"` 22 | Y float64 `json:"y,omitzero" jsonschema:"description=Y coordinate,example=8"` 23 | } 24 | -------------------------------------------------------------------------------- /examples/calculator/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package calculator 20 | -------------------------------------------------------------------------------- /examples/calculator/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/calculator/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package calculator 20 | 21 | const Version = 314 22 | const SourceCodeSHA256 = "bf4c2e2f5e97fdb1823f7a72eb9350239ec1564908e6197f2b085a1fd3dea756" 23 | const Timestamp = "2025-06-08T01:36:00.100102Z" 24 | 25 | /* { 26 | "ver": 314, 27 | "sha256": "bf4c2e2f5e97fdb1823f7a72eb9350239ec1564908e6197f2b085a1fd3dea756", 28 | "ts": "2025-06-08T01:36:00.100102Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/calculator/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package calculator 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestCalculator_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/directory/app/directory/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/directory" 28 | ) 29 | 30 | // main runs an app containing only the directory.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(directory.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/directory/directoryapi/personkey.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package directoryapi 18 | 19 | // PersonKey is the primary key of the person. 20 | type PersonKey int 21 | -------------------------------------------------------------------------------- /examples/directory/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package directory 20 | -------------------------------------------------------------------------------- /examples/directory/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/directory/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package directory 20 | 21 | const Version = 249 22 | const SourceCodeSHA256 = "537b962d96359c2f424ea63696ebb2cedae6b333895b93c9b289974c5ca4cd76" 23 | const Timestamp = "2025-06-08T01:36:00.206965Z" 24 | 25 | /* { 26 | "ver": 249, 27 | "sha256": "537b962d96359c2f424ea63696ebb2cedae6b333895b93c9b289974c5ca4cd76", 28 | "ts": "2025-06-08T01:36:00.206965Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/directory/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package directory 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestDirectory_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/eventsink/app/eventsink/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/eventsink" 28 | ) 29 | 30 | // main runs an app containing only the eventsink.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(eventsink.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/eventsink/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package eventsink 20 | -------------------------------------------------------------------------------- /examples/eventsink/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/eventsink/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package eventsink 20 | 21 | const Version = 229 22 | const SourceCodeSHA256 = "e74fa421d57b7c7275ddc30fc3600af94c5834390265877cda5e4ee15fe781fa" 23 | const Timestamp = "2025-06-08T01:36:00.315791Z" 24 | 25 | /* { 26 | "ver": 229, 27 | "sha256": "e74fa421d57b7c7275ddc30fc3600af94c5834390265877cda5e4ee15fe781fa", 28 | "ts": "2025-06-08T01:36:00.315791Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/eventsink/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package eventsink 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestEventsink_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/eventsource/app/eventsource/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/eventsource" 28 | ) 29 | 30 | // main runs an app containing only the eventsource.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(eventsource.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/eventsource/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package eventsource 20 | -------------------------------------------------------------------------------- /examples/eventsource/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/eventsource/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package eventsource 20 | 21 | const Version = 233 22 | const SourceCodeSHA256 = "b2ee65d146c6a1b6898d41715890e5f4c5c34e769ce6970b23d799fe5912d1ed" 23 | const Timestamp = "2025-06-08T01:36:00.42145Z" 24 | 25 | /* { 26 | "ver": 233, 27 | "sha256": "b2ee65d146c6a1b6898d41715890e5f4c5c34e769ce6970b23d799fe5912d1ed", 28 | "ts": "2025-06-08T01:36:00.42145Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/eventsource/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package eventsource 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestEventsource_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/hello/app/hello/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/hello" 28 | ) 29 | 30 | // main runs an app containing only the hello.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(hello.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/hello/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package hello 20 | -------------------------------------------------------------------------------- /examples/hello/resources/bus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microbus-io/fabric/c6ef012b1f7f99aead7392499db9b1991801ad45/examples/hello/resources/bus.png -------------------------------------------------------------------------------- /examples/hello/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/hello/resources/strings.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2025 Microbus LLC and various contributors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | --- 16 | hello: 17 | en: Hello 18 | fr: Bonjour 19 | es: Hola 20 | it: Salve 21 | de: Guten Tag 22 | pt: Olá 23 | da: Goddag 24 | nl: Goedendag 25 | pl: Dzień dobry 26 | no: God dag 27 | tr: Merhaba 28 | sv: God dag 29 | -------------------------------------------------------------------------------- /examples/hello/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package hello 20 | 21 | const Version = 290 22 | const SourceCodeSHA256 = "8f2d53a1d5ea863211c923db2febd6202d94c258567c449f6f44fbe007251d94" 23 | const Timestamp = "2025-06-08T01:36:00.540973Z" 24 | 25 | /* { 26 | "ver": 290, 27 | "sha256": "8f2d53a1d5ea863211c923db2febd6202d94c258567c449f6f44fbe007251d94", 28 | "ts": "2025-06-08T01:36:00.540973Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/hello/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package hello 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestHello_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/helloworld/app/helloworld/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/helloworld" 28 | ) 29 | 30 | // main runs an app containing only the helloworld.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(helloworld.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/helloworld/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package helloworld 20 | -------------------------------------------------------------------------------- /examples/helloworld/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/helloworld/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package helloworld 20 | 21 | const Version = 45 22 | const SourceCodeSHA256 = "bef04c20e0d64c75a7c34e470c64b0b288b1f37bcba9336fc7fcccb4e5240c4f" 23 | const Timestamp = "2025-06-08T01:36:00.647397Z" 24 | 25 | /* { 26 | "ver": 45, 27 | "sha256": "bef04c20e0d64c75a7c34e470c64b0b288b1f37bcba9336fc7fcccb4e5240c4f", 28 | "ts": "2025-06-08T01:36:00.647397Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/helloworld/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package helloworld 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestHelloworld_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/login/app/login/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/login" 28 | ) 29 | 30 | // main runs an app containing only the login.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(login.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/login/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package login 20 | -------------------------------------------------------------------------------- /examples/login/resources/admin-only.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | Admin Only 20 | 26 | 27 | 28 |

For Admin Eyes Only

29 | If you can see this page, you're an admin. 30 | 31 | -------------------------------------------------------------------------------- /examples/login/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/login/resources/manager-only.html: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | Manager Only 20 | 26 | 27 | 28 |

For Manager Eyes Only

29 | If you can see this page, you're a manager. 30 | 31 | -------------------------------------------------------------------------------- /examples/login/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package login 20 | 21 | const Version = 62 22 | const SourceCodeSHA256 = "b609c37edce424a78a640347ce981ce5b77543ef955eb64fb2ae594ef3ecace1" 23 | const Timestamp = "2025-06-08T01:36:00.752968Z" 24 | 25 | /* { 26 | "ver": 62, 27 | "sha256": "b609c37edce424a78a640347ce981ce5b77543ef955eb64fb2ae594ef3ecace1", 28 | "ts": "2025-06-08T01:36:00.752968Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/login/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package login 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestLogin_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/messaging/app/messaging/main-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package main 20 | 21 | import ( 22 | "fmt" 23 | "os" 24 | 25 | "github.com/microbus-io/fabric/application" 26 | 27 | "github.com/microbus-io/fabric/examples/messaging" 28 | ) 29 | 30 | // main runs an app containing only the messaging.example service. 31 | func main() { 32 | app := application.New() 33 | app.Add(messaging.NewService()) 34 | err := app.Run() 35 | if err != nil { 36 | fmt.Fprintf(os.Stderr, "%+v", err) 37 | os.Exit(19) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/messaging/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | //go:generate go run github.com/microbus-io/fabric/codegen 18 | 19 | package messaging 20 | -------------------------------------------------------------------------------- /examples/messaging/resources/embed-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package resources 20 | 21 | import "embed" 22 | 23 | //go:embed * 24 | var FS embed.FS 25 | 26 | /* 27 | Files placed in the resources directory are bundled with the executable and are accessible via svc.ResFS or 28 | any of the convenience methods svc.ReadResFile, svc.ReadResTextFile, svc.ExecuteResTemplate, svc.ServeResFile, etc. 29 | 30 | A file named strings.yaml can be used to store internationalized strings that can be loaded via svc.LoadResString 31 | to best match the locale in the context. The YAML is expected to be in the following format: 32 | 33 | stringKey: 34 | default: Localized 35 | en: Localized 36 | en-GB: Localised 37 | fr: Localisée 38 | 39 | If a default is not provided, English (en) is used as the fallback language. 40 | String keys and locale names are case insensitive. 41 | */ 42 | -------------------------------------------------------------------------------- /examples/messaging/version-gen.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package messaging 20 | 21 | const Version = 200 22 | const SourceCodeSHA256 = "0e029965199e2005713eda5d993b096425d194889f0d346c30ee1657281486cd" 23 | const Timestamp = "2025-06-08T01:36:00.857382Z" 24 | 25 | /* { 26 | "ver": 200, 27 | "sha256": "0e029965199e2005713eda5d993b096425d194889f0d346c30ee1657281486cd", 28 | "ts": "2025-06-08T01:36:00.857382Z" 29 | } */ 30 | -------------------------------------------------------------------------------- /examples/messaging/version-gen_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Code generated by Microbus. DO NOT EDIT. 18 | 19 | package messaging 20 | 21 | import ( 22 | "os" 23 | "testing" 24 | 25 | "github.com/microbus-io/fabric/utils" 26 | "github.com/microbus-io/testarossa" 27 | ) 28 | 29 | func TestMessaging_Versioning(t *testing.T) { 30 | t.Parallel() 31 | tt := testarossa.For(t) 32 | 33 | hash, err := utils.SourceCodeSHA256(".") 34 | if tt.NoError(err) { 35 | tt.Equal(hash, SourceCodeSHA256, "SourceCodeSHA256 is not up to date") 36 | } 37 | buf, err := os.ReadFile("version-gen.go") 38 | if tt.NoError(err) { 39 | tt.Contains(string(buf), hash, "SHA256 in version-gen.go is not up to date") 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /httpx/bodyreader_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package httpx 18 | 19 | import ( 20 | "io" 21 | "testing" 22 | 23 | "github.com/microbus-io/testarossa" 24 | ) 25 | 26 | func TestHttpx_BodyReader(t *testing.T) { 27 | t.Parallel() 28 | tt := testarossa.For(t) 29 | 30 | bin := []byte("Lorem Ipsum") 31 | br := NewBodyReader(bin) 32 | bout, err := io.ReadAll(br) 33 | tt.NoError(err) 34 | tt.Equal(bin, bout) 35 | tt.Equal(bin, br.Bytes()) 36 | br.Reset() 37 | bout, err = io.ReadAll(br) 38 | tt.NoError(err) 39 | tt.Equal(bin, bout) 40 | tt.Equal(bin, br.Bytes()) 41 | err = br.Close() 42 | tt.NoError(err) 43 | } 44 | -------------------------------------------------------------------------------- /httpx/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package httpx includes various HTTP utilities. 19 | */ 20 | package httpx 21 | -------------------------------------------------------------------------------- /httpx/qargs_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package httpx 18 | 19 | import ( 20 | "testing" 21 | 22 | "github.com/microbus-io/testarossa" 23 | ) 24 | 25 | func TestHttpx_QArgs(t *testing.T) { 26 | t.Parallel() 27 | tt := testarossa.For(t) 28 | 29 | tt.Equal("b=true&i=123&s=String", QArgs{ 30 | "s": "String", 31 | "i": 123, 32 | "b": true, 33 | }.Encode()) 34 | tt.Equal("b=true&i=123&s=String", QArgs{ 35 | "s": "String", 36 | "i": 123, 37 | "b": true, 38 | }.String()) 39 | 40 | urlValues := QArgs{ 41 | "s": "String", 42 | "i": 123, 43 | "b": true, 44 | }.URLValues() 45 | tt.Equal([]string{"String"}, urlValues["s"]) 46 | tt.Equal([]string{"123"}, urlValues["i"]) 47 | tt.Equal([]string{"true"}, urlValues["b"]) 48 | } 49 | -------------------------------------------------------------------------------- /main/config.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2025 Microbus LLC and various contributors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | hello.example: 16 | Repeat: 3 17 | Greeting: Ciao 18 | 19 | http.ingress.core: 20 | # Ports: 8080 21 | # TimeBudget: 20s 22 | 23 | directory.example: 24 | SQL: "root:secret1234@tcp(127.0.0.1:3306)/microbus_examples" 25 | -------------------------------------------------------------------------------- /openapi/endpoint.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package openapi 18 | 19 | // Endpoint describes a single endpoint of a microservice, such as an RPC function. 20 | type Endpoint struct { 21 | Type string 22 | Name string 23 | Path string 24 | Summary string 25 | Description string 26 | InputArgs any 27 | OutputArgs any 28 | Method string 29 | Actor string 30 | } 31 | -------------------------------------------------------------------------------- /pub/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package pub is used for the publishing of requests. 19 | It contains the options to use in Connector.Publish 20 | */ 21 | package pub 22 | -------------------------------------------------------------------------------- /pub/response.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package pub 18 | 19 | import "net/http" 20 | 21 | // Response is a union of an http.Response and an error. 22 | // Only one or the other is valid 23 | type Response struct { 24 | res *http.Response 25 | err error 26 | } 27 | 28 | // Get returns the http.Response or error stored in the composite Response 29 | func (r *Response) Get() (*http.Response, error) { 30 | return r.res, r.err 31 | } 32 | 33 | // NewErrorResponse creates a new response containing an error 34 | func NewErrorResponse(err error) *Response { 35 | return &Response{err: err} 36 | } 37 | 38 | // NewResponse creates a new response containing an http.Response 39 | func NewHTTPResponse(res *http.Response) *Response { 40 | return &Response{res: res} 41 | } 42 | -------------------------------------------------------------------------------- /pub/response_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package pub 18 | 19 | import ( 20 | "errors" 21 | "net/http" 22 | "testing" 23 | 24 | "github.com/microbus-io/testarossa" 25 | ) 26 | 27 | func TestPub_Response(t *testing.T) { 28 | t.Parallel() 29 | tt := testarossa.For(t) 30 | 31 | myErr := errors.New("my error") 32 | r := NewErrorResponse(myErr) 33 | res, err := r.Get() 34 | tt.Nil(res) 35 | tt.Equal(&myErr, &err) 36 | 37 | var myRes http.Response 38 | r = NewHTTPResponse(&myRes) 39 | res, err = r.Get() 40 | tt.NoError(err) 41 | tt.Equal(&myRes, res) 42 | } 43 | -------------------------------------------------------------------------------- /rand/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package rand is a collection of utility functions for generating random numbers and identifiers. 19 | */ 20 | package rand 21 | -------------------------------------------------------------------------------- /rand/rand_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package rand 18 | 19 | import ( 20 | "regexp" 21 | "testing" 22 | 23 | "github.com/microbus-io/testarossa" 24 | ) 25 | 26 | func BenchmarkRand_AlphaNum64(b *testing.B) { 27 | for b.Loop() { 28 | AlphaNum64(16) 29 | } 30 | // On 2021 MacBook M1 Pro 16": 42 ns/op 31 | } 32 | 33 | func TestRand_AlphaNum64(t *testing.T) { 34 | t.Parallel() 35 | tt := testarossa.For(t) 36 | 37 | re := regexp.MustCompile(`^[a-zA-Z0-9]+$`) 38 | for i := 1; i < 1024; i++ { 39 | an64 := AlphaNum64(i) 40 | tt.Len(an64, i) 41 | match := re.MatchString(an64) 42 | tt.True(match) 43 | } 44 | } 45 | 46 | func TestRand_AlphaNum32(t *testing.T) { 47 | t.Parallel() 48 | tt := testarossa.For(t) 49 | 50 | re := regexp.MustCompile(`^[A-Z0-9]+$`) 51 | for i := 1; i < 1024; i++ { 52 | an32 := AlphaNum32(i) 53 | tt.Len(an32, i) 54 | match := re.MatchString(an32) 55 | tt.True(match) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /setup/grafana/dashboards/dashboards.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2025 Microbus LLC and various contributors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards 16 | 17 | apiVersion: 1 18 | 19 | providers: 20 | - name: 'Microbus' 21 | orgId: 1 22 | folder: '' 23 | type: file 24 | disableDeletion: false 25 | allowUiUpdates: true 26 | options: 27 | path: /otel-lgtm/grafana/conf/provisioning/dashboards 28 | -------------------------------------------------------------------------------- /setup/microbus.yaml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023-2025 Microbus LLC and various contributors 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | services: 16 | lgtm: 17 | image: grafana/otel-lgtm 18 | ports: 19 | - "3000:3000" 20 | - "4317:4317" 21 | - "4318:4318" 22 | networks: 23 | - microbus-network 24 | volumes: 25 | - ./grafana/dashboards:/otel-lgtm/grafana/conf/provisioning/dashboards 26 | nats: 27 | image: nats:2-alpine 28 | ports: 29 | - "8222:8222" 30 | - "4222:4222" 31 | networks: 32 | - microbus-network 33 | networks: 34 | microbus-network: 35 | -------------------------------------------------------------------------------- /sub/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package sub is used for subscribing to handle requests. 19 | It contains the options to use in Connector.Subscribe 20 | */ 21 | package sub 22 | -------------------------------------------------------------------------------- /trc/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package trc is used for working with tracing spans. 18 | // It contains the options to use in Connector.StartSpan 19 | package trc 20 | -------------------------------------------------------------------------------- /utils/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | /* 18 | Package utils is an assortment of independent utilities. 19 | */ 20 | package utils 21 | -------------------------------------------------------------------------------- /utils/panic.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "github.com/microbus-io/fabric/errors" 21 | ) 22 | 23 | // CatchPanic calls the given function and returns any panic as a standard error. 24 | // Deprecated: Use [errors.CatchPanic] instead. 25 | func CatchPanic(f func() error) (err error) { 26 | return errors.CatchPanic(f) 27 | } 28 | -------------------------------------------------------------------------------- /utils/sourcecodehash_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023-2025 Microbus LLC and various contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package utils 18 | 19 | import ( 20 | "encoding/hex" 21 | "testing" 22 | 23 | "github.com/microbus-io/testarossa" 24 | ) 25 | 26 | func TestUtils_SourceCodeHash(t *testing.T) { 27 | t.Parallel() 28 | tt := testarossa.For(t) 29 | 30 | h, err := SourceCodeSHA256(".") 31 | tt.NoError(err) 32 | b, err := hex.DecodeString(h) 33 | tt.NoError(err) 34 | tt.Len(b, 256/8) 35 | } 36 | --------------------------------------------------------------------------------