Skip to content

Commit

Permalink
feat: rename send package to rpc
Browse files Browse the repository at this point in the history
Also makes some method names more explicit.

Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Apr 15, 2024
1 parent 276e25f commit 713b26e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions internal/cmd/cli/Invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/nats-io/nats.go"
"golang.org/x/sync/errgroup"

"github.com/brianmcgee/cbus/pkg/send"
"github.com/brianmcgee/cbus/pkg/rpc"
nutil "github.com/numtide/nits/pkg/nats"
)

Expand All @@ -23,7 +23,7 @@ type Invoke struct {
}

func (i *Invoke) Run() (err error) {
if err = send.Init(i.Nats); err != nil {
if err = rpc.Init(i.Nats); err != nil {
return err
}

Expand All @@ -34,7 +34,7 @@ func (i *Invoke) Run() (err error) {

eg, ctx := errgroup.WithContext(ctx)
eg.Go(func() error {
return send.Method(ctx, i.Destination, i.Path, i.Property, respCh, i.Nkeys...)
return rpc.InvokeMethod(ctx, i.Destination, i.Path, i.Property, respCh, i.Nkeys...)
})

for msg := range respCh {
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/cli/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/nats-io/nats.go"
"golang.org/x/sync/errgroup"

"github.com/brianmcgee/cbus/pkg/send"
"github.com/brianmcgee/cbus/pkg/rpc"
nutil "github.com/numtide/nits/pkg/nats"
)

Expand All @@ -23,7 +23,7 @@ type Get struct {
}

func (g *Get) Run() (err error) {
if err = send.Init(g.Nats); err != nil {
if err = rpc.Init(g.Nats); err != nil {
return err
}

Expand All @@ -34,7 +34,7 @@ func (g *Get) Run() (err error) {

eg, ctx := errgroup.WithContext(ctx)
eg.Go(func() error {
return send.Get(ctx, g.Destination, g.Path, g.Property, respCh, g.Nkeys...)
return rpc.GetProperty(ctx, g.Destination, g.Path, g.Property, respCh, g.Nkeys...)
})

for msg := range respCh {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func Init(natsConfig nutil.CliOptions) (err error) {
return errors.Annotate(err, "failed to connect to system dbus")
}

// create a separate monitor connection, it can only be used to listen for messages, not send
// create a separate monitor connection, it can only be used to listen for messages, not rpc
monitorConn, err = dbus.ConnectSystemBus()
if err != nil {
return errors.Annotate(err, "failed to connect to system dbus")
Expand Down
10 changes: 5 additions & 5 deletions pkg/send/send.go → pkg/rpc/rpc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package send
package rpc

import (
"context"
Expand Down Expand Up @@ -47,7 +47,7 @@ func request(
name,
)

// send the request
// rpc the request
msg := nats.NewMsg(subject)
msg.Reply = inbox

Expand All @@ -66,7 +66,7 @@ func request(
name,
)

// send the request
// rpc the request
msg := nats.NewMsg(subject)
msg.Reply = inbox

Expand All @@ -93,7 +93,7 @@ func request(
}
}

func Get(
func GetProperty(
ctx context.Context,
dest string,
path string,
Expand All @@ -104,7 +104,7 @@ func Get(
return request(ctx, dest, path, "prop", name, respCh, nkeys...)
}

func Method(
func InvokeMethod(
ctx context.Context,
dest string,
path string,
Expand Down

0 comments on commit 713b26e

Please sign in to comment.