Skip to content

Commit

Permalink
comments and ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
crazybber committed Nov 27, 2020
1 parent d154a26 commit ef13eca
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ _cgo_export.*
*.swp
*.swo
*.orig
__debug_bin
2 changes: 2 additions & 0 deletions app/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions app/codec/bytes/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/gonitro/nitro/app/codec"
)

//Codec for byte
type Codec struct {
Conn io.ReadWriteCloser
}
Expand Down
3 changes: 3 additions & 0 deletions app/codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ import (
"io"
)

//Message Type for codec
const (
Error MessageType = iota
Request
Response
Event
)

//Error Message
var (
ErrInvalidMessage = errors.New("invalid message")
)

//MessageType define
type MessageType int

// Takes in a connection/buffer and returns a new Codec
Expand Down
19 changes: 14 additions & 5 deletions app/crypto/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"
)

//NewOptions for crypto
func NewOptions(opts ...Option) Options {
var options Options
for _, o := range opts {
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -163,19 +166,21 @@ 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
// Issuer of the account
Issuer string
}

//TokenOption to set TokenOptions
type TokenOption func(o *TokenOptions)

// WithExpiry for the token
Expand Down Expand Up @@ -211,26 +216,30 @@ 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
}

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 {
return func(o *VerifyOptions) {
o.Context = ctx
}
}

//VerifyNamespace for crypto
func VerifyNamespace(ns string) VerifyOption {
return func(o *VerifyOptions) {
o.Namespace = ns
Expand Down
5 changes: 3 additions & 2 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"version": "0.1",
"words": [
"words":[
"pgrpc",
"urfave",
"gonitro"
"gonitro",
"JWTs"
]
}

0 comments on commit ef13eca

Please sign in to comment.