roc

command module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 0 Imported by: 0

README ΒΆ

Roc

logo

GitHub Workflow Status Go Report Card Go Reference GitHub GitHub release (latest SemVer including pre-releases)

πŸ‘‹ Roc is a rpc micro framework,it designed with go,and transport protocol by rsocket-go.


IT IS UNDER ACTIVE DEVELOPMENT, APIs are unstable and maybe change at any time until release of v1.0.0.

πŸ‘€ Features
  • Simple to use ✨
  • Lightweight ✨
  • High performance ✨
  • Service discovery ✨
  • Support websocket and socket same time ✨
  • Support json or gogo proto when use rpc ✨
🌱 Quick start
  • first you must install proto and etcd

  • install protoc-gen-roc

    GO111MODULE= on go get github.com/go -roc/roc/cmd/protoc-gen-roc
    protoc --roc_out = plugins = roc:.*.proto
  • run a roc service
package main

import (
    "github.com/go-roc/roc/_auxiliary/example/hello/app/api/api.hello/hello"
    "github.com/go-roc/roc/_auxiliary/example/hello/proto/phello"
    "github.com/go-roc/roc/rlog"
    "github.com/go-roc/roc/service"
)

func main() {
    s := service.New(
        service.HttpAddress("0.0.0.0:9999"),
        service.Namespace("api.hello"),
        service.TCPAddress("0.0.0.0:8888"),
        service.WssAddress("0.0.0.0:10000", "/hello"),
    )

    phello.RegisterHelloWorldServer(s.Server(), &hello.Hello{Client: s.Client()})
    err := s.Run()
    if err != nil {
        rlog.Error(err)
    }
}
  • config help
package main

import (
    "fmt"

    "github.com/go-roc/roc/config"

    _ "github.com/go-roc/roc/internal/etcd/mock"
)

func main() {

    //new config use default option
    err := config.NewConfig()
    if err != nil {
        panic(err)
    }

    const key = "test"
    var result struct {
        Name string `json:"name"`
        Age  int    `json:"age"`
    }

    coverPublic(key, &result)
    coverPrivate(key, &result)
}

//put key/value to etcd:
//go:generate etcdctl put  configroc/v1.0.0/public/roc.test "{ "name":"roc", "age":18 }"
func coverPublic(key string, v interface{}) {
    //simple public use
    //the key is roc.test
    err := config.DecodePublic(key, v)
    if err != nil {
        panic(err)
    }

    fmt.Println("------", v)
    //output: ------ {roc 18}
}

//put key/value to etcd:
//go:generate etcdctl put  configroc/v1.0.0/private/test "{ "name":"roc", "age":18 }"
func coverPrivate(key string, v interface{}) {
    //the key is test
    err := config.DecodePrivate(key, v)
    if err != nil {
        panic(err)
    }

    fmt.Println("------", v)
    //output: ------ {roc 18}
}

πŸ’žοΈ see more example for more help.
πŸ“« How to reach me and be a contributor ...
✨ TODO ✨
  • bench test
  • sidecar
  • more example
  • more singleton tests
  • generate dir
  • command for request service
  • sidecar service
  • config service
  • broker redirect request service
  • logger service
  • simple service GUI

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
_auxiliary
cmd
roc
roc/rocx
Package rocx enable project default generator
Package rocx enable project default generator
internal
sig
metadata
Package metadata for websocket or socket from rsocket-rpc-go Metadata
Package metadata for websocket or socket from rsocket-rpc-go Metadata
plugin
log
opt
x
fs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL