github.com/altipla-consulting/ravendb-go-client@v0.1.3/hi_lo_return_command.go (about)

     1  package ravendb
     2  
     3  import (
     4  	"net/http"
     5  )
     6  
     7  var (
     8  	_ RavenCommand = &HiLoReturnCommand{}
     9  )
    10  
    11  // HiLoReturnCommand represents "hi lo return" command
    12  type HiLoReturnCommand struct {
    13  	RavenCommandBase
    14  
    15  	tag  string
    16  	last int64
    17  	end  int64
    18  }
    19  
    20  // NewHiLoReturnCommand returns a new HiLoReturnCommand
    21  func NewHiLoReturnCommand(tag string, last int64, end int64) (*HiLoReturnCommand, error) {
    22  	if last < 0 {
    23  		return nil, newIllegalArgumentError("last is < 0")
    24  	}
    25  	if end < 0 {
    26  		return nil, newIllegalArgumentError("end is < 0")
    27  	}
    28  	if tag == "" {
    29  		return nil, newIllegalArgumentError("tag cannot be empty")
    30  	}
    31  
    32  	cmd := &HiLoReturnCommand{
    33  		RavenCommandBase: NewRavenCommandBase(),
    34  
    35  		tag:  tag,
    36  		last: last,
    37  		end:  end,
    38  	}
    39  	cmd.IsReadRequest = true
    40  	cmd.ResponseType = RavenCommandResponseTypeEmpty
    41  	return cmd, nil
    42  }
    43  
    44  func (c *HiLoReturnCommand) createRequest(node *ServerNode) (*http.Request, error) {
    45  	url := node.URL + "/databases/" + node.Database + "/hilo/return?tag=" + c.tag + "&end=" + i64toa(c.end) + "&last=" + i64toa(c.last)
    46  
    47  	return newHttpPut(url, nil)
    48  }