Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsannm committed Jun 30, 2024
1 parent 39fc13d commit 45312a6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion example/ex-08-echo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/clubpay/ronykit/example/ex-08-echo
go 1.22

require (
github.com/clubpay/ronykit/kit v0.16.0
github.com/clubpay/ronykit/kit v0.16.2
github.com/clubpay/ronykit/rony v0.16.0
)

Expand Down
4 changes: 2 additions & 2 deletions example/ex-08-echo/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/clubpay/ronykit/contrib v0.16.0 h1:p/l9Et3qAX8UzJz3vFBOuVyCCmNQ6v9ykzEYpOzjQXs=
github.com/clubpay/ronykit/contrib v0.16.0/go.mod h1:83nIpriVSQdcGGNS+o8pH9tmPUj3CkBXueRTRcjqCw0=
github.com/clubpay/ronykit/kit v0.16.0 h1:89nrRSXVc0FaLNcHzShRZqtaRrk7hFjE5TVgkOZUkWk=
github.com/clubpay/ronykit/kit v0.16.0/go.mod h1:JmRsAjBYhNsrU7iaQM9oVw5OSIQpMET+VDKx1suUPbk=
github.com/clubpay/ronykit/kit v0.16.2 h1:/mZgfpKcRoZIaKmi7G4vRxazFcqeqkIjtHO0OheE5qA=
github.com/clubpay/ronykit/kit v0.16.2/go.mod h1:JmRsAjBYhNsrU7iaQM9oVw5OSIQpMET+VDKx1suUPbk=
github.com/clubpay/ronykit/rony v0.16.0 h1:qgZNYjlxpj9lfndnnjIKBwVtl7vcJnOSJ3jpv4TH8qY=
github.com/clubpay/ronykit/rony v0.16.0/go.mod h1:uykkwC8QnhK1VrXKeGjaQe9QzyWtYZgVs7F+75wZtIQ=
github.com/clubpay/ronykit/std/gateways/fasthttp v0.16.0 h1:+hw9yPt/b2vgnAE1UaXKrvHdT23Gd0xm7rtIMJNK3Bg=
Expand Down
1 change: 0 additions & 1 deletion rony/server_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
type serverConfig struct {
serverName string
version string
desc string
services map[string]*desc.Service
edgeOpts []kit.Option
gatewayOpts []fasthttp.Option
Expand Down
2 changes: 0 additions & 2 deletions rony/setup_unary.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package rony

import (
"reflect"
"sync"

"github.com/clubpay/ronykit/kit"
Expand Down Expand Up @@ -59,7 +58,6 @@ func registerUnary[IN, OUT Message, S State[A], A Action](
c := desc.NewContract().
In(&in).
Out(&out).
SetName(reflect.TypeOf(h).Name()).
SetHandler(handlers...)

if setupCtx.nodeSel != nil {
Expand Down
10 changes: 8 additions & 2 deletions rony/stub.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package rony

import "github.com/clubpay/ronykit/stub/stubgen"
import (
"github.com/clubpay/ronykit/kit/utils"
"github.com/clubpay/ronykit/stub/stubgen"
)

// GenerateStub generates a stub file for the given service description.
// The generated file will be placed in the `outputDir/folderName` directory.
Expand All @@ -11,8 +14,11 @@ func GenerateStub[S State[A], A Action](
genFunc stubgen.GenFunc, ext string,
opt ...SetupOption[S, A],
) error {
var s S
ctx := SetupContext[S, A]{
cfg: &serverConfig{},
s: utils.ValPtr(ToInitiateState(s)()),
name: name,
cfg: &serverConfig{},
}
for _, o := range opt {
o(&ctx)
Expand Down
18 changes: 18 additions & 0 deletions ronyup/internal/skeleton/rony/cmd/gen-stub/main.go.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"github.com/clubpay/ronykit/rony"
"github.com/clubpay/ronykit/stub/stubgen"
"{{ .ModulePath }}/service"
)

func main() {
err := rony.GenerateStub(
"Counter", "counter", "./stub", "counterc",
stubgen.GolangStub, ".go",
service.Setup(),
)
if err != nil {
panic(err)
}
}
7 changes: 5 additions & 2 deletions ronyup/internal/skeleton/rony/service/setup.go.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ func Setup() rony.SetupOption[*state.Counter, state.Action] {
// 4. GET /count?action=down&count=2
rony.WithUnary(
endpoint.Count,
rony.GET("/count/{action}"),
rony.GET("/count/{action}", rony.UnaryName("Count")),
rony.GET("/count"),
),
// Register the count reset handler for both GET /reset and POST /reset
rony.WithUnary(
endpoint.Reset,
rony.GET("/reset"),
rony.GET("/reset", rony.UnaryName("Reset")),
rony.POST("/reset"),
),
)
}


//go:generate go run {{.ModulePath}}/cmd/gen-stub/main.go
func init() {}

0 comments on commit 45312a6

Please sign in to comment.