{"id":19935802,"url":"https://github.com/alonza0314/lotus","last_synced_at":"2025-10-07T11:41:50.074Z","repository":{"id":252684306,"uuid":"838584800","full_name":"Alonza0314/lotus","owner":"Alonza0314","description":"An interesting golang module combining QUIC (HTTP/3) with a traditional RPC framework.","archived":false,"fork":false,"pushed_at":"2024-08-12T20:24:31.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T02:38:03.530Z","etag":null,"topics":["go","http3","lotus","quic","rpc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alonza0314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"security/cert.go","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-06T00:31:22.000Z","updated_at":"2024-11-13T16:05:56.000Z","dependencies_parsed_at":"2024-11-12T23:33:18.306Z","dependency_job_id":null,"html_url":"https://github.com/Alonza0314/lotus","commit_stats":null,"previous_names":["alonza0314/lotus"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alonza0314%2Flotus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alonza0314%2Flotus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alonza0314%2Flotus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alonza0314%2Flotus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alonza0314","download_url":"https://codeload.github.com/Alonza0314/lotus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241361759,"owners_count":19950444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","http3","lotus","quic","rpc"],"created_at":"2024-11-12T23:22:08.225Z","updated_at":"2025-10-07T11:41:45.022Z","avatar_url":"https://github.com/Alonza0314.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LOTUS\n\n## Description\n\nThis is a golang module to implement a new RPC technology based on QUIC.\n\nThe QUIC module is imported from: [quic-go](https://github.com/quic-go/quic-go).\n\n## Development Environment\n\n| Content | Implememt | Version |\n|-|-|-|\n| OS | Linux | Ubuntu 22.04.4 LTS  |\n| Language | Golang | go1.22.5 linux/amd64 |\n|PKI|TLS|1.3|\n\n## How to use\n\nUse this command to get this module:\n\n```bash\ngo get github.com/Alonza0314/lotus@latest\n```\n\n### Server\n\n1. Import this module.\n\n    ``` go\n    import \"github.com/Alonza0314/lotus/server\"\n    ```\n\n2. Prepare your own pem using in TLS communication(QUIC required).\n\n    ```go\n    penPath := \"test.pem\"\n    ```\n\n3. Init a lotus server.\n\n    ```go\n    lserver, err := server.NewLotusServer(\"test.pem\")\n    ```\n\n4. Write your service function and decide this funtion's identifier. Be careful that do not use \"int\" directly. Instead, use float64 to represent the number's type, since the json module does not distinguish \"int\" and \"float64\".\n\n    ```go\n    // identifier = \"add\"\n    func add(a, b interface{}) float64 {\n        return a.(float64) + b.(float64)\n    }\n    ```\n\n5. Register this function with its identifier to lotus server.\n\n    ```go\n    err = lserver.RegisterService(\"add\", add)\n    ```\n\n6. Call listen function to get lotus Listener and asign the listening address and port.\n\n    ```go\n    llistener, err := lserver.Listen(\":4433\")\n    ```\n\n7. Use a for loop to call accept function to accept the client's coinnection.\n\n    ```go\n    lconn, err := llistener.Accept(context.Background())\n    ```\n\n8. Whenever there exists a new connection, use go routine to handle it. Be caerful that you need to pass the lotus server information since the function is register in the lotus server structure.\n\n    ```go\n    for {\n        lconn, err := llistener.Accept(context.Background())\n        if err != nil {\n            // TODO\n            continue\n        }\n        go lconn.HandleFunc(*lserver)\n    }\n    ```\n\n### Client\n\n1. Import this module.\n\n    ``` go\n    import \"github.com/Alonza0314/lotus/client\"\n    ```\n\n2. Init a lotus client. The first arg is the address and the port. The other is a bool value to identity if the tls pem used by server is signed by it self or signed by public.\n\n    ```go\n    lclient, err := client.NewLotusClient(\":4433\", true)\n    ```\n\n3. Make a dail to the server.\n\n    ```go\n    lconn, err := lclient.Dial(context.Background())\n    ```\n\n4. Defer the close function.\n\n    ```go\n    defer lconn.Close()\n    ```\n\n5. Set the Service identifier and arges slice and the reply slice. Be careful that the type of args and reply is interface slice.\n\n    ```go\n    function, args, reply := \"add\", []interface{}{1, 2}, []interface{}{}\n    ```\n\n6. Call the service function.\n\n    ```go\n    err := lconn.Call(context.Background(), function, args, \u0026reply)\n    ```\n\n7. Make a type assertion on the reply according to the function definition.\n\n    ```go\n    response := reply[0].(float64)\n    ```\n\n## Author\n\nYou can know more about the author through this link: [Alonza](https://alonza0314.github.io/)\n\n## BlaBla\n\nIf you think this project is helpful, please give me a little start! thanks!\n\nOr, if there is any question or suggestion, feel free to contact me!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonza0314%2Flotus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falonza0314%2Flotus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falonza0314%2Flotus/lists"}