Browse Source

Init repo

master
commit
f39cf583b9
Signed by: chris GPG Key ID: 3025DCBD46F81C0F
  1. 10
      README.org
  2. 59
      flake.lock
  3. 44
      flake.nix
  4. 3
      go.mod
  5. 137
      proto/users.pb.go
  6. 11
      proto/users.proto
  7. 109
      proto/users_grpc.pb.go

10
README.org

@ -0,0 +1,10 @@
#+TITLE: Users
#+AUTHOR: Christopher James Hayward
#+EMAIL: chris@chrishayward.xyz
* Instructions
1. Clone this repository: ~git clone https://git.chrishayward.xyz/x/users.git && cd users~
2. Load the development shell: ~nix develop~
3. Build the application: ~users-build~
4. Run the test server: ~users-run~

59
flake.lock

@ -0,0 +1,59 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1687709756,
"narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1688100262,
"narHash": "sha256-RlyMyeya6hClpgyMtKLYjf/watrWpyvlwInj8+d94lc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3c614fbc76fc152f3e1bc4b2263da6d90adf80fb",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

44
flake.nix

@ -0,0 +1,44 @@
{
description = "User management system.";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs @ { self, nixpkgs, ... }:
inputs.flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system};
myProtoc = "${pkgs.grpc-tools}/bin/protoc";
myUsersDir = "$MY_USERS_DIR";
myUsersBuild = pkgs.writeShellScriptBin "users-build" ''
pushd ${myUsersDir} > /dev/null &&
${myProtoc} --proto_path=${myUsersDir} \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
proto/users.proto &&
popd > /dev/null
'';
in
rec {
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
go
gopls
protoc-gen-go
protoc-gen-go-grpc
grpc
grpcui
grpcurl
grpc-tools
myUsersBuild
];
shellHook = ''
export MY_USERS_DIR="$(pwd)"
'';
};
}
);
}

3
go.mod

@ -0,0 +1,3 @@
module git.chrishayward.xyz/x/users
go 1.20

137
proto/users.pb.go

@ -0,0 +1,137 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.29.1
// protoc v3.15.6
// source: proto/users.proto
package proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type None struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *None) Reset() {
*x = None{}
if protoimpl.UnsafeEnabled {
mi := &file_proto_users_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *None) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*None) ProtoMessage() {}
func (x *None) ProtoReflect() protoreflect.Message {
mi := &file_proto_users_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use None.ProtoReflect.Descriptor instead.
func (*None) Descriptor() ([]byte, []int) {
return file_proto_users_proto_rawDescGZIP(), []int{0}
}
var File_proto_users_proto protoreflect.FileDescriptor
var file_proto_users_proto_rawDesc = []byte{
0x0a, 0x11, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x06, 0x0a, 0x04, 0x4e, 0x6f,
0x6e, 0x65, 0x32, 0x2b, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x22, 0x0a, 0x04, 0x54,
0x65, 0x73, 0x74, 0x12, 0x0b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2e, 0x4e, 0x6f, 0x6e, 0x65,
0x1a, 0x0b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2e, 0x4e, 0x6f, 0x6e, 0x65, 0x22, 0x00, 0x42,
0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x68, 0x72, 0x69, 0x73, 0x68, 0x61, 0x79, 0x77,
0x61, 0x72, 0x64, 0x2e, 0x78, 0x79, 0x7a, 0x2f, 0x78, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_proto_users_proto_rawDescOnce sync.Once
file_proto_users_proto_rawDescData = file_proto_users_proto_rawDesc
)
func file_proto_users_proto_rawDescGZIP() []byte {
file_proto_users_proto_rawDescOnce.Do(func() {
file_proto_users_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_users_proto_rawDescData)
})
return file_proto_users_proto_rawDescData
}
var file_proto_users_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_proto_users_proto_goTypes = []interface{}{
(*None)(nil), // 0: users.None
}
var file_proto_users_proto_depIdxs = []int32{
0, // 0: users.Users.Test:input_type -> users.None
0, // 1: users.Users.Test:output_type -> users.None
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_proto_users_proto_init() }
func file_proto_users_proto_init() {
if File_proto_users_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_proto_users_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*None); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_proto_users_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_proto_users_proto_goTypes,
DependencyIndexes: file_proto_users_proto_depIdxs,
MessageInfos: file_proto_users_proto_msgTypes,
}.Build()
File_proto_users_proto = out.File
file_proto_users_proto_rawDesc = nil
file_proto_users_proto_goTypes = nil
file_proto_users_proto_depIdxs = nil
}

11
proto/users.proto

@ -0,0 +1,11 @@
syntax = "proto3";
package users;
option go_package = "git.chrishayward.xyz/x/users/proto";
service Users {
rpc Test(None) returns (None) {}
}
message None { }

109
proto/users_grpc.pb.go

@ -0,0 +1,109 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.15.6
// source: proto/users.proto
package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
Users_Test_FullMethodName = "/users.Users/Test"
)
// UsersClient is the client API for Users service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type UsersClient interface {
Test(ctx context.Context, in *None, opts ...grpc.CallOption) (*None, error)
}
type usersClient struct {
cc grpc.ClientConnInterface
}
func NewUsersClient(cc grpc.ClientConnInterface) UsersClient {
return &usersClient{cc}
}
func (c *usersClient) Test(ctx context.Context, in *None, opts ...grpc.CallOption) (*None, error) {
out := new(None)
err := c.cc.Invoke(ctx, Users_Test_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// UsersServer is the server API for Users service.
// All implementations must embed UnimplementedUsersServer
// for forward compatibility
type UsersServer interface {
Test(context.Context, *None) (*None, error)
mustEmbedUnimplementedUsersServer()
}
// UnimplementedUsersServer must be embedded to have forward compatible implementations.
type UnimplementedUsersServer struct {
}
func (UnimplementedUsersServer) Test(context.Context, *None) (*None, error) {
return nil, status.Errorf(codes.Unimplemented, "method Test not implemented")
}
func (UnimplementedUsersServer) mustEmbedUnimplementedUsersServer() {}
// UnsafeUsersServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to UsersServer will
// result in compilation errors.
type UnsafeUsersServer interface {
mustEmbedUnimplementedUsersServer()
}
func RegisterUsersServer(s grpc.ServiceRegistrar, srv UsersServer) {
s.RegisterService(&Users_ServiceDesc, srv)
}
func _Users_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(None)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UsersServer).Test(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Users_Test_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UsersServer).Test(ctx, req.(*None))
}
return interceptor(ctx, in, info, handler)
}
// Users_ServiceDesc is the grpc.ServiceDesc for Users service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Users_ServiceDesc = grpc.ServiceDesc{
ServiceName: "users.Users",
HandlerType: (*UsersServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Test",
Handler: _Users_Test_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "proto/users.proto",
}
Loading…
Cancel
Save