Skip to content

Commit e1bbf4d

Browse files
author
Maksym Trofimenko
committed
initial commit
1 parent c9a3a79 commit e1bbf4d

File tree

8 files changed

+661
-1
lines changed

8 files changed

+661
-1
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Build & publish module to the Tiny Systems
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- uses: actions/setup-go@v4
13+
- run: |
14+
echo "Preparing a release"
15+
echo "Module name ${{ github.event.repository.name }}"
16+
go mod tidy
17+
go run cmd/main.go tools build --version ${{github.ref_name}} --name github.com/${{ github.repository }} --devkey ${{secrets.TINY_DEV_SECRET}}

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
11+
node_modules
12+
dist
13+
dist-ssr
14+
*.local
15+
16+
# Editor directories and files
17+
.vscode/*
18+
!.vscode/extensions.json
19+
.idea
20+
.DS_Store
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?
26+
.npmrc

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Tiny Systems
3+
Copyright (c) 2023 Maksym Trofimenko
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Tiny Systems All-In-One module
2+
Collection of various components combined into the first module.

cmd/main.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/rs/zerolog"
7+
"github.com/spf13/cobra"
8+
"github.com/spf13/viper"
9+
_ "github.com/tiny-systems/example-module/components/echo"
10+
"github.com/tiny-systems/module/cli"
11+
"os"
12+
"os/signal"
13+
"syscall"
14+
)
15+
16+
// RootCmd represents the base command when called without any subcommands
17+
var rootCmd = &cobra.Command{
18+
Use: "server",
19+
Short: "tiny-system's example module",
20+
Run: func(cmd *cobra.Command, args []string) {
21+
cmd.Help()
22+
},
23+
}
24+
25+
func main() {
26+
// Default level for this example is info, unless debug flag is present
27+
zerolog.SetGlobalLevel(zerolog.InfoLevel)
28+
viper.AutomaticEnv()
29+
if viper.GetBool("debug") {
30+
zerolog.SetGlobalLevel(zerolog.DebugLevel)
31+
}
32+
33+
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
34+
defer stop()
35+
36+
cli.RegisterCommands(rootCmd)
37+
if err := rootCmd.ExecuteContext(ctx); err != nil {
38+
fmt.Printf("command execute error: %v\n", err)
39+
}
40+
}

components/echo/modify.go

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package echo
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"github.com/tiny-systems/module/module"
7+
"github.com/tiny-systems/module/registry"
8+
)
9+
10+
const (
11+
ComponentName = "echo"
12+
InPort string = "in"
13+
OutPort string = "out"
14+
)
15+
16+
type Context any
17+
18+
type InMessage struct {
19+
Context Context `json:"context" configurable:"true" required:"true" title:"Context" description:"Arbitrary message to be modified"`
20+
}
21+
22+
type Component struct {
23+
}
24+
25+
func (t *Component) Instance() module.Component {
26+
return &Component{}
27+
}
28+
29+
func (t *Component) GetInfo() module.ComponentInfo {
30+
return module.ComponentInfo{
31+
Name: ComponentName,
32+
Description: "Echo",
33+
Info: "Sends the same message as it receives",
34+
Tags: []string{"Echo", "Demo"},
35+
}
36+
}
37+
38+
func (t *Component) Handle(ctx context.Context, handler module.Handler, port string, msg interface{}) error {
39+
if in, ok := msg.(InMessage); ok {
40+
return handler(ctx, OutPort, in.Context)
41+
}
42+
return fmt.Errorf("invalid message")
43+
}
44+
45+
func (t *Component) Ports() []module.Port {
46+
return []module.Port{
47+
{
48+
Name: InPort,
49+
Label: "In",
50+
Source: true,
51+
Configuration: InMessage{},
52+
Position: module.Left,
53+
},
54+
{
55+
Name: OutPort,
56+
Label: "Out",
57+
Source: false,
58+
Configuration: new(Context),
59+
Position: module.Right,
60+
},
61+
}
62+
}
63+
64+
var _ module.Component = (*Component)(nil)
65+
66+
func init() {
67+
registry.Register(&Component{})
68+
}

go.mod

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
module github.com/tiny-systems/example-module
2+
3+
go 1.23.1
4+
5+
require (
6+
github.com/rs/zerolog v1.31.0
7+
github.com/spf13/cobra v1.8.0
8+
github.com/spf13/viper v1.19.0
9+
github.com/tiny-systems/module v0.1.86
10+
)
11+
12+
require (
13+
github.com/Microsoft/go-winio v0.6.1 // indirect
14+
github.com/beorn7/perks v1.0.1 // indirect
15+
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
16+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
17+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
18+
github.com/distribution/reference v0.5.0 // indirect
19+
github.com/docker/distribution v2.8.3+incompatible // indirect
20+
github.com/docker/docker v24.0.6+incompatible // indirect
21+
github.com/docker/go-connections v0.4.0 // indirect
22+
github.com/docker/go-units v0.5.0 // indirect
23+
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
24+
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
25+
github.com/fsnotify/fsnotify v1.7.0 // indirect
26+
github.com/getkin/kin-openapi v0.124.0 // indirect
27+
github.com/go-logr/logr v1.4.1 // indirect
28+
github.com/go-logr/stdr v1.2.2 // indirect
29+
github.com/go-logr/zerologr v1.2.3 // indirect
30+
github.com/go-openapi/jsonpointer v0.20.2 // indirect
31+
github.com/go-openapi/jsonreference v0.20.2 // indirect
32+
github.com/go-openapi/swag v0.22.8 // indirect
33+
github.com/goccy/go-json v0.10.2 // indirect
34+
github.com/gogo/protobuf v1.3.2 // indirect
35+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
36+
github.com/golang/protobuf v1.5.3 // indirect
37+
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
38+
github.com/google/go-cmp v0.6.0 // indirect
39+
github.com/google/gofuzz v1.2.0 // indirect
40+
github.com/google/uuid v1.6.0 // indirect
41+
github.com/gorilla/mux v1.8.1 // indirect
42+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1 // indirect
43+
github.com/hashicorp/hcl v1.0.0 // indirect
44+
github.com/imdario/mergo v0.3.16 // indirect
45+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
46+
github.com/invopop/yaml v0.2.0 // indirect
47+
github.com/josharian/intern v1.0.0 // indirect
48+
github.com/json-iterator/go v1.1.12 // indirect
49+
github.com/magiconair/properties v1.8.7 // indirect
50+
github.com/mailru/easyjson v0.7.7 // indirect
51+
github.com/mattn/go-colorable v0.1.13 // indirect
52+
github.com/mattn/go-isatty v0.0.20 // indirect
53+
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
54+
github.com/mitchellh/mapstructure v1.5.0 // indirect
55+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
56+
github.com/modern-go/reflect2 v1.0.2 // indirect
57+
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
58+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
59+
github.com/oapi-codegen/oapi-codegen/v2 v2.3.0 // indirect
60+
github.com/opencontainers/go-digest v1.0.0 // indirect
61+
github.com/opencontainers/image-spec v1.0.2 // indirect
62+
github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect
63+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
64+
github.com/perimeterx/marshmallow v1.1.5 // indirect
65+
github.com/pkg/errors v0.9.1 // indirect
66+
github.com/prometheus/client_golang v1.18.0 // indirect
67+
github.com/prometheus/client_model v0.5.0 // indirect
68+
github.com/prometheus/common v0.45.0 // indirect
69+
github.com/prometheus/procfs v0.12.0 // indirect
70+
github.com/rogpeppe/go-internal v1.12.0 // indirect
71+
github.com/sagikazarmark/locafero v0.4.0 // indirect
72+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
73+
github.com/sourcegraph/conc v0.3.0 // indirect
74+
github.com/spf13/afero v1.11.0 // indirect
75+
github.com/spf13/cast v1.6.0 // indirect
76+
github.com/spf13/pflag v1.0.5 // indirect
77+
github.com/spyzhov/ajson v0.9.4 // indirect
78+
github.com/subosito/gotenv v1.6.0 // indirect
79+
github.com/swaggest/jsonschema-go v0.3.70 // indirect
80+
github.com/swaggest/refl v1.3.0 // indirect
81+
github.com/tiny-systems/errorpanic v0.7.1 // indirect
82+
github.com/tiny-systems/platform-api v0.0.10 // indirect
83+
go.opentelemetry.io/contrib/instrumentation/runtime v0.46.1 // indirect
84+
go.opentelemetry.io/otel v1.24.0 // indirect
85+
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.44.0 // indirect
86+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
87+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect
88+
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect
89+
go.opentelemetry.io/otel/metric v1.24.0 // indirect
90+
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
91+
go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect
92+
go.opentelemetry.io/otel/trace v1.24.0 // indirect
93+
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
94+
go.uber.org/atomic v1.11.0 // indirect
95+
go.uber.org/multierr v1.11.0 // indirect
96+
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
97+
golang.org/x/mod v0.17.0 // indirect
98+
golang.org/x/net v0.25.0 // indirect
99+
golang.org/x/oauth2 v0.18.0 // indirect
100+
golang.org/x/sync v0.7.0 // indirect
101+
golang.org/x/sys v0.20.0 // indirect
102+
golang.org/x/term v0.20.0 // indirect
103+
golang.org/x/text v0.15.0 // indirect
104+
golang.org/x/time v0.5.0 // indirect
105+
golang.org/x/tools v0.21.0 // indirect
106+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
107+
google.golang.org/appengine v1.6.8 // indirect
108+
google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect
109+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect
110+
google.golang.org/grpc v1.62.1 // indirect
111+
google.golang.org/protobuf v1.33.0 // indirect
112+
gopkg.in/inf.v0 v0.9.1 // indirect
113+
gopkg.in/ini.v1 v1.67.0 // indirect
114+
gopkg.in/yaml.v2 v2.4.0 // indirect
115+
gopkg.in/yaml.v3 v3.0.1 // indirect
116+
k8s.io/api v0.29.2 // indirect
117+
k8s.io/apiextensions-apiserver v0.29.1 // indirect
118+
k8s.io/apimachinery v0.29.2 // indirect
119+
k8s.io/client-go v0.29.2 // indirect
120+
k8s.io/component-base v0.29.1 // indirect
121+
k8s.io/klog/v2 v2.120.1 // indirect
122+
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
123+
k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect
124+
sigs.k8s.io/controller-runtime v0.17.2 // indirect
125+
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
126+
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
127+
sigs.k8s.io/yaml v1.4.0 // indirect
128+
)
129+
130+
replace github.com/spyzhov/ajson v0.9.4 => github.com/tiny-systems/ajson v0.1.3

0 commit comments

Comments
 (0)