Skip to content

Commit

Permalink
Fix punctuation (#5)
Browse files Browse the repository at this point in the history
* Fix punctuation

* Fix punctuation
  • Loading branch information
f0rmiga committed Nov 9, 2018
1 parent 98951e7 commit fc4eb18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions sessiongate.go
Expand Up @@ -15,30 +15,30 @@ type Sessiongate struct {
signKey []byte
}

// NewSessiongate initializes a new Sessiongate
// NewSessiongate initializes a new Sessiongate.
func NewSessiongate(config *Config) (*Sessiongate, error) {
// Returns an error if SignKey is not set
if config.SignKey == nil {
return nil, errors.New("SignKey is required for the Sessiongate config")
}

// Sets addr to a default value if it is an empty string
// Sets addr to a default value if it is an empty string.
var addr string
if config.Addr == "" {
addr = ":6379"
} else {
addr = config.Addr
}

// Sets maxIdle to a default value if it is 0
// Sets maxIdle to a default value if it is 0.
var maxIdle int
if config.MaxIdle == 0 {
maxIdle = 3
} else {
maxIdle = config.MaxIdle
}

// Sets idleTimeout to a default value if it is 0
// Sets idleTimeout to a default value if it is 0.
var idleTimeout time.Duration
if config.IdleTimeout == 0 {
idleTimeout = 240 * time.Second
Expand All @@ -48,21 +48,21 @@ func NewSessiongate(config *Config) (*Sessiongate, error) {

sessiongate := new(Sessiongate)

// Initialize the Redis connection pool
// Initialize the Redis connection pool.
sessiongate.redisPool = &redis.Pool{
MaxIdle: maxIdle,
IdleTimeout: idleTimeout,
Dial: func() (redis.Conn, error) { return redis.Dial("tcp", addr) },
}

// Sets the SignKey passed to config
// Sets the SignKey passed to config.
sessiongate.signKey = config.SignKey

return sessiongate, nil
}

// Start starts a new session in the SessionGate module and returns the
// generated token
// generated token.
func (sessiongate *Sessiongate) Start(ttl int) ([]byte, error) {
conn := sessiongate.redisPool.Get()
defer conn.Close()
Expand All @@ -75,7 +75,7 @@ func (sessiongate *Sessiongate) Start(ttl int) ([]byte, error) {
return r.([]byte), nil
}

// Expire sets the TTL for a session in the SessionGate module
// Expire sets the TTL for a session in the SessionGate module.
func (sessiongate *Sessiongate) Expire(token []byte, ttl int) error {
conn := sessiongate.redisPool.Get()
defer conn.Close()
Expand All @@ -95,7 +95,7 @@ func (sessiongate *Sessiongate) PSet(token, name, payload []byte) error {
}

// PGet gets a payload for a session in the SessionGate module
// name is the payload name
// name is the payload name.
func (sessiongate *Sessiongate) PGet(token, name []byte) ([]byte, error) {
conn := sessiongate.redisPool.Get()
defer conn.Close()
Expand All @@ -109,7 +109,7 @@ func (sessiongate *Sessiongate) PGet(token, name []byte) ([]byte, error) {
}

// PDel deletes a payload for a session in the SessionGate module
// name is the payload name to be used to delete
// name is the payload name to be used to delete.
func (sessiongate *Sessiongate) PDel(token, name []byte) error {
conn := sessiongate.redisPool.Get()
defer conn.Close()
Expand All @@ -118,7 +118,7 @@ func (sessiongate *Sessiongate) PDel(token, name []byte) error {
return err
}

// End ends a session in the SessionGate module
// End ends a session in the SessionGate module.
func (sessiongate *Sessiongate) End(token []byte) error {
conn := sessiongate.redisPool.Get()
defer conn.Close()
Expand Down
14 changes: 7 additions & 7 deletions sessiongate_test.go
Expand Up @@ -16,7 +16,7 @@ func init() {
rand.Read(signKey)
}

// TestInitializer tests the Sessiongate initializer
// TestInitializer tests the Sessiongate initializer.
func TestInitializer(t *testing.T) {
t.Run("Should fail with missing SignKey", func(t *testing.T) {
config := &Config{}
Expand All @@ -28,7 +28,7 @@ func TestInitializer(t *testing.T) {
})
}

// TestStart tests the START command for the SessionGate module
// TestStart tests the START command for the SessionGate module.
func TestStart(t *testing.T) {
t.Run("Should fail with negative TTL", func(t *testing.T) {
config := &Config{
Expand Down Expand Up @@ -117,7 +117,7 @@ func createSession() (*Sessiongate, []byte, error) {
return sessiongate, token, nil
}

// TestExpire tests the EXPIRE command for the SessionGate module
// TestExpire tests the EXPIRE command for the SessionGate module.
func TestExpire(t *testing.T) {
sessiongate, token, err := createSession()
if err != nil {
Expand All @@ -139,7 +139,7 @@ func TestExpire(t *testing.T) {
})
}

// TestPSet tests the PSET command for the SessionGate module
// TestPSet tests the PSET command for the SessionGate module.
func TestPSet(t *testing.T) {
sessiongate, token, err := createSession()
if err != nil {
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestPSet(t *testing.T) {
})
}

// TestPGet tests the PGET command for the SessionGate module
// TestPGet tests the PGET command for the SessionGate module.
func TestPGet(t *testing.T) {
sessiongate, token, err := createSession()
if err != nil {
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestPGet(t *testing.T) {
})
}

// TestPDel tests the PDEL command for the SessionGate module
// TestPDel tests the PDEL command for the SessionGate module.
func TestPDel(t *testing.T) {
sessiongate, token, err := createSession()
if err != nil {
Expand Down Expand Up @@ -389,7 +389,7 @@ func TestPDel(t *testing.T) {
})
}

// TestEnd tests the END command for the SessionGate module
// TestEnd tests the END command for the SessionGate module.
func TestEnd(t *testing.T) {
sessiongate, token, err := createSession()
if err != nil {
Expand Down

0 comments on commit fc4eb18

Please sign in to comment.