From ef13eca4d6e5c654acc8451aee36924f8514ba55 Mon Sep 17 00:00:00 2001 From: Edward Date: Fri, 27 Nov 2020 14:55:18 +0800 Subject: [PATCH] comments and ignore --- .gitignore | 1 + app/cache/cache.go | 2 ++ app/codec/bytes/bytes.go | 1 + app/codec/codec.go | 3 +++ app/crypto/options.go | 19 ++++++++++++++----- cspell.json | 5 +++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index e3bad6db..bf852ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ _cgo_export.* *.swp *.swo *.orig +__debug_bin diff --git a/app/cache/cache.go b/app/cache/cache.go index 75833ee4..fa775e95 100644 --- a/app/cache/cache.go +++ b/app/cache/cache.go @@ -13,10 +13,12 @@ type Cache interface { String() string } +//Options for cache type Options struct { Nodes []string } +//Option to set Options type Option func(o *Options) // Nodes sets the nodes for the cache diff --git a/app/codec/bytes/bytes.go b/app/codec/bytes/bytes.go index 199e11a6..8359d663 100644 --- a/app/codec/bytes/bytes.go +++ b/app/codec/bytes/bytes.go @@ -9,6 +9,7 @@ import ( "github.com/gonitro/nitro/app/codec" ) +//Codec for byte type Codec struct { Conn io.ReadWriteCloser } diff --git a/app/codec/codec.go b/app/codec/codec.go index eae7c3f3..848a237c 100644 --- a/app/codec/codec.go +++ b/app/codec/codec.go @@ -6,6 +6,7 @@ import ( "io" ) +//Message Type for codec const ( Error MessageType = iota Request @@ -13,10 +14,12 @@ const ( Event ) +//Error Message var ( ErrInvalidMessage = errors.New("invalid message") ) +//MessageType define type MessageType int // Takes in a connection/buffer and returns a new Codec diff --git a/app/crypto/options.go b/app/crypto/options.go index 9d5bc871..47eac510 100644 --- a/app/crypto/options.go +++ b/app/crypto/options.go @@ -5,6 +5,7 @@ import ( "time" ) +//NewOptions for crypto func NewOptions(opts ...Option) Options { var options Options for _, o := range opts { @@ -13,8 +14,8 @@ func NewOptions(opts ...Option) Options { return options } -type Options struct { - // Issuer of the service's account +//Options for crypto +type Options struct { // Issuer of the service's account Issuer string // ID is the services auth ID ID string @@ -34,6 +35,7 @@ type Options struct { Context context.Context } +//Option to set Options type Option func(o *Options) // Addrs is the auth addresses to use @@ -99,10 +101,11 @@ type GenerateOptions struct { Secret string // Issuer of the account, e.g. micro Issuer string - // Name of the acouunt e.g. an email or username + // Name of the account e.g. an email or username Name string } +//GenerateOption to set GenerateOptions type GenerateOption func(o *GenerateOptions) // WithSecret for the generated account @@ -163,12 +166,13 @@ func NewGenerateOptions(opts ...GenerateOption) GenerateOptions { return options } +//TokenOptions for crypto type TokenOptions struct { // ID for the account ID string // Secret for the account Secret string - // RefreshToken is used to refesh a token + // RefreshToken is used to refresh a token RefreshToken string // Expiry is the time the token should live for Expiry time.Duration @@ -176,6 +180,7 @@ type TokenOptions struct { Issuer string } +//TokenOption to set TokenOptions type TokenOption func(o *TokenOptions) // WithExpiry for the token @@ -211,7 +216,7 @@ func NewTokenOptions(opts ...TokenOption) TokenOptions { o(&options) } - // set defualt expiry of token + // set default expiry of token if options.Expiry == 0 { options.Expiry = time.Minute } @@ -219,11 +224,13 @@ func NewTokenOptions(opts ...TokenOption) TokenOptions { return options } +//VerifyOptions for crypto type VerifyOptions struct { Context context.Context Namespace string } +//VerifyOption for crypto type VerifyOption func(o *VerifyOptions) func VerifyContext(ctx context.Context) VerifyOption { @@ -231,6 +238,8 @@ func VerifyContext(ctx context.Context) VerifyOption { o.Context = ctx } } + +//VerifyNamespace for crypto func VerifyNamespace(ns string) VerifyOption { return func(o *VerifyOptions) { o.Namespace = ns diff --git a/cspell.json b/cspell.json index cb398a93..8f564d22 100644 --- a/cspell.json +++ b/cspell.json @@ -1,8 +1,9 @@ { "version": "0.1", - "words": [ + "words":[ "pgrpc", "urfave", - "gonitro" + "gonitro", + "JWTs" ] } \ No newline at end of file