Skip to content

Commit

Permalink
updating servicemesh library
Browse files Browse the repository at this point in the history
  • Loading branch information
gravestench committed Dec 17, 2023
1 parent 8ab55e6 commit ff67208
Show file tree
Hide file tree
Showing 39 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion cmd/bare_minimum/example_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type example struct {
name string
}

func (e *example) Init(mesh servicemesh.M) {
func (e *example) Init(mesh servicemesh.Mesh) {
return
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/charm/simple_tui/bubbletea_wrapper_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type bubbleteaService struct {
mux sync.Mutex
}

func (b *bubbleteaService) Init(mesh servicemesh.M) {
func (b *bubbleteaService) Init(mesh servicemesh.Mesh) {
go b.runLoop()

b.bindExisting(mesh)
Expand All @@ -40,7 +40,7 @@ func (b *bubbleteaService) runLoop() {
}
}

func (b *bubbleteaService) bindExisting(mesh servicemesh.M) {
func (b *bubbleteaService) bindExisting(mesh servicemesh.Mesh) {
var models []tea.Model

for _, service := range mesh.Services() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/charm/simple_tui/filepicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type filePickerService struct {
model *filePickerModel
}

func (t *filePickerService) Init(mesh servicemesh.M) {
func (t *filePickerService) Init(mesh servicemesh.Mesh) {
t.model = &filePickerModel{}
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/config_file/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type serviceThatUsesConfigManager struct {
log *slog.Logger
}

func (s *serviceThatUsesConfigManager) ResolveDependencies(mesh servicemesh.M) {
func (s *serviceThatUsesConfigManager) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if instance, ok := service.(config_file.Manager); ok {
s.configManager = instance
Expand All @@ -31,7 +31,7 @@ func (s *serviceThatUsesConfigManager) DependenciesResolved() bool {
return s.configManager != nil
}

func (s *serviceThatUsesConfigManager) Init(mesh servicemesh.M) {
func (s *serviceThatUsesConfigManager) Init(mesh servicemesh.Mesh) {
cfg, err := s.configManager.GetConfig("test.json")
if err != nil {
s.log.Error("couldn't load example config file", "error", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s *Service) ResolveDependencies(_ pkg.IsRuntime) {
// to call Init unless until we have resolved our deps ourselves.
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s *Service) A() string {
return "this message came from ServiceA"
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
s.log.Info("calling B()", "message from B", s.dependency.B())
return
}
Expand All @@ -46,7 +46,7 @@ func (s *Service) DependenciesResolved() bool {
return s.dependency != nil
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
// here, we iterate over all services from the runtime
// and check if the service implements something we need.
for _, service := range mesh.Services() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (s *Service) B() string {
return "this message came from ServiceB"
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
s.log.Info("calling A()", "message from A", s.dependency.A())
return
}
Expand All @@ -46,7 +46,7 @@ func (s *Service) DependenciesResolved() bool {
return s.dependency != nil
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
// here, we iterate over all services from the runtime
// and check if the service implements something we need.
for _, service := range mesh.Services() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/events/custom_events/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (r *receiver) Logger() *slog.Logger {
return r.logger
}

func (r *receiver) Init(mesh servicemesh.M) {
func (r *receiver) Init(mesh servicemesh.Mesh) {
mesh.Events().On("test", func(args ...any) {
r.logger.Info("event received", "event", "test", "args", args)
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/events/custom_events/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (s *sender) Logger() *slog.Logger {
return s.logger
}

func (s *sender) Init(mesh servicemesh.M) {
func (s *sender) Init(mesh servicemesh.Mesh) {
s.logger.Info("emitting 'test' event in 3 seconds...")

time.Sleep(time.Second * 3)
Expand Down
2 changes: 1 addition & 1 deletion cmd/events/runtime_events/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (s *listensForNewServices) Logger() *slog.Logger {
return s.logger
}

func (s *listensForNewServices) Init(mesh servicemesh.M) {
func (s *listensForNewServices) Init(mesh servicemesh.Mesh) {
// noop
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/events/runtime_events/other_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type exampleService struct {
name string
}

func (e *exampleService) Init(mesh servicemesh.M) {
func (e *exampleService) Init(mesh servicemesh.Mesh) {
// noop
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/graceful_shutdown/example_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (e *example) Logger() *slog.Logger {
return e.l
}

func (e *example) Init(mesh servicemesh.M) {
func (e *example) Init(mesh servicemesh.Mesh) {
return
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/log_level/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type service struct {
logger *slog.Logger
}

func (s *service) Init(mesh servicemesh.M) {
func (s *service) Init(mesh servicemesh.Mesh) {
mesh.SetLogLevel(int(slog.LevelWarn))
s.logger.Debug("you should not see this")
s.logger.Info("you should not see this")
Expand Down
4 changes: 2 additions & 2 deletions cmd/text_to_speech/example_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ func (s *exampleServiceThatUsesTts) DependenciesResolved() bool {
return s.tts != nil
}

func (s *exampleServiceThatUsesTts) ResolveDependencies(mesh servicemesh.M) {
func (s *exampleServiceThatUsesTts) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if candidate, ok := service.(text_to_speech.ConvertsTextToSpeech); ok {
s.tts = candidate
}
}
}

func (s *exampleServiceThatUsesTts) Init(mesh servicemesh.M) {
func (s *exampleServiceThatUsesTts) Init(mesh servicemesh.Mesh) {
go s.loopSpeakRandomStuff()
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/twitch_integrated_text_to_speech/twitch_to_tts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ func (g *glueService) DependenciesResolved() bool {
return g.tts != nil
}

func (g *glueService) ResolveDependencies(mesh servicemesh.M) {
func (g *glueService) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if candidate, ok := service.(text_to_speech.ConvertsTextToSpeech); ok {
g.tts = candidate
}
}
}

func (g *glueService) Init(mesh servicemesh.M) {
func (g *glueService) Init(mesh servicemesh.Mesh) {
// do nothing
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/web_api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var (

type exampleRouteInitializer struct{}

func (s *exampleRouteInitializer) Init(mesh servicemesh.M) {
func (s *exampleRouteInitializer) Init(mesh servicemesh.Mesh) {
// nothing to do
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/gin-gonic/gin v1.9.1
github.com/google/uuid v1.5.0
github.com/gravestench/runtime v0.0.0-20231002182113-640425b821c6
github.com/gravestench/servicemesh v0.0.0-20231216212722-f13d113b25b2
github.com/gravestench/servicemesh v0.0.0-20231217212458-b62100fdfd7a
github.com/hegedustibor/htgo-tts v0.0.0-20230402053941-cd8d1a158135
golang.org/x/oauth2 v0.15.0
k8s.io/utils v0.0.0-20231127182322-b307cd553661
Expand Down
4 changes: 2 additions & 2 deletions services/cli_flags/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *Service) Logger() *slog.Logger {
return s.log
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
s.args = make([]string, len(os.Args))
copy(s.args, os.Args)

Expand All @@ -49,7 +49,7 @@ func (s *Service) Name() string {
return "CLI Flags"
}

func (s *Service) loopApplyFlags(manager servicemesh.M) {
func (s *Service) loopApplyFlags(manager servicemesh.Mesh) {
for {
for _, candidate := range manager.Services() {
s.applyFlags(candidate)
Expand Down
2 changes: 1 addition & 1 deletion services/config_file/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *Service) Name() string {
}

// Init satisfies the servicemesh.IsRuntimeService interface
func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
s.configs = make(map[string]*Config)
s.servicesWithDefaultConfigs = make(map[string]HasDefaultConfig)

Expand Down
4 changes: 2 additions & 2 deletions services/desktop_notification/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Service struct {
cfgManager config_file.Manager
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {

}

Expand All @@ -35,7 +35,7 @@ func (s *Service) DependenciesResolved() bool {
return s.cfgManager != nil
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
for _, candidate := range mesh.Services() {
if service, ok := candidate.(config_file.Manager); ok {
s.cfgManager = service
Expand Down
2 changes: 1 addition & 1 deletion services/raylib_renderer/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (s *Service) DependenciesResolved() bool {
return true
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if candidate, ok := service.(config_file.Manager); ok {
s.cfgManager = candidate
Expand Down
4 changes: 2 additions & 2 deletions services/raylib_renderer/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *Service) initRenderer() {
})
}

func (s *Service) gatherLayers(mesh servicemesh.M) {
func (s *Service) gatherLayers(mesh servicemesh.Mesh) {
for {
for _, service := range mesh.Services() {
if _, alreadyBound := s.layers[service.Name()]; alreadyBound {
Expand All @@ -46,7 +46,7 @@ func (s *Service) gatherLayers(mesh servicemesh.M) {
}
}

func (s *Service) renderServicesAsLayers(mesh servicemesh.M) {
func (s *Service) renderServicesAsLayers(mesh servicemesh.Mesh) {
s.mux.Lock()
defer s.mux.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion services/raylib_renderer/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Service struct {
order []string
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
defer func() { _ = recover() /* don't worry about it */ }()

if s.layers == nil {
Expand Down
2 changes: 1 addition & 1 deletion services/text_to_speech/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (s *Service) DependenciesResolved() bool {
return true
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if candidate, ok := service.(config_file.Manager); ok {
s.cfgManager = candidate
Expand Down
2 changes: 1 addition & 1 deletion services/text_to_speech/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Service struct {
speech htgotts.Speech
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
var cfg *config_file.Config

for { // wait until the config or default config is saved + loaded
Expand Down
2 changes: 1 addition & 1 deletion services/twitch_auth_code_grant_flow/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ func (s *Service) DependenciesResolved() bool {
return s.cfg != nil
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if candidate, ok := service.(config_file.Dependency); ok {
s.cfg = candidate
Expand Down
2 changes: 1 addition & 1 deletion services/twitch_auth_code_grant_flow/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Service struct {
token string
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {

}

Expand Down
2 changes: 1 addition & 1 deletion services/twitch_integration/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (s *Service) DependenciesResolved() bool {
return true
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if candidate, ok := service.(config_file.Dependency); ok {
s.cfgManager = candidate
Expand Down
2 changes: 1 addition & 1 deletion services/twitch_integration/event_handler_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

// loopBindHandlers iterates over all services every second and binds event
// handlers for services that implement interfaces found in abstract.go
func (s *Service) loopBindHandlers(mesh servicemesh.M) {
func (s *Service) loopBindHandlers(mesh servicemesh.Mesh) {
// we will keep track service we've already bound
bound := make(map[string]any)

Expand Down
2 changes: 1 addition & 1 deletion services/twitch_integration/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Service struct {
twitchIrcClient *twitch.Client
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
go s.setupClient()
go s.loopBindHandlers(mesh)
}
Expand Down
2 changes: 1 addition & 1 deletion services/twitch_soundboard/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/gravestench/servicemesh-examples/services/desktop_notification"
)

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
for _, service := range mesh.Services() {
if instance, ok := service.(config_file.Manager); ok {
s.configManager = instance
Expand Down
2 changes: 1 addition & 1 deletion services/twitch_soundboard/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Service struct {
log *slog.Logger
}

func (s *Service) Init(mesh servicemesh.M) {
func (s *Service) Init(mesh servicemesh.Mesh) {
// nothing to do
}

Expand Down
2 changes: 1 addition & 1 deletion services/web_router/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (s *Service) DependenciesResolved() bool {
return true
}

func (s *Service) ResolveDependencies(mesh servicemesh.M) {
func (s *Service) ResolveDependencies(mesh servicemesh.Mesh) {
for _, other := range mesh.Services() {
if cfg, ok := other.(config_file.Manager); ok {
s.cfgManager = cfg
Expand Down
Loading

0 comments on commit ff67208

Please sign in to comment.