Loading blockconnection.go +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ type BlockConnection struct { nbc *NonBlockConnection } // Helper function to establish block connection to device. func NewBlockConnection(op ClientOptions) (*BlockConnection, error) { nbc, err := NewNonBlockConnection(op) if err != nil { Loading callback.go +13 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,11 @@ import ( kproto "github.com/yongzhy/kinetic-go/proto" ) // Callback is the interface define actions for MessageType. // Success is called when XXXXX_RESPONSE message recieved from drive without problem. // Failure is called when XXXXX_RESPONSE message status code is not OK, or any other kind of failure. // Done return true if either Success or Failure is called to indicate XXXXX_RESPONSE received and processed. // Status return the MessateType operation status. type Callback interface { Success(resp *kproto.Command, value []byte) Failure(status Status) Loading @@ -11,7 +16,8 @@ type Callback interface { Status() Status } // Generic Callback, for Message which doesn't require data from Kinetic drive. // Generic Callback, can be used for all MessageType which doesn't require data from Kinetic drive. // And for MessageType that require data from drive, a new struct need to be defined GenericCallback type GenericCallback struct { done bool status Status Loading Loading @@ -40,9 +46,11 @@ func (c *GenericCallback) Status() Status { // Callback for Command_GET Message type GetCallback struct { GenericCallback Entry Record Entry Record // Entity information } // Success function extracts object information from kinetic message protocol and // store into GetCallback.Entry. func (c *GetCallback) Success(resp *kproto.Command, value []byte) { c.GenericCallback.Success(resp, value) c.Entry.Key = resp.GetBody().GetKeyValue().GetKey() Loading @@ -56,7 +64,7 @@ func (c *GetCallback) Success(resp *kproto.Command, value []byte) { // Callback for Command_GETKEYRANGE Message type GetKeyRangeCallback struct { GenericCallback Keys [][]byte Keys [][]byte // List of objects' keys within range, get from device } func (c *GetKeyRangeCallback) Success(resp *kproto.Command, value []byte) { Loading @@ -67,7 +75,7 @@ func (c *GetKeyRangeCallback) Success(resp *kproto.Command, value []byte) { // Callback for Command_GETVERSION Message type GetVersionCallback struct { GenericCallback Version []byte Version []byte // Version of the object on device } func (c *GetVersionCallback) Success(resp *kproto.Command, value []byte) { Loading @@ -93,7 +101,7 @@ func (c *P2PPushCallback) Success(resp *kproto.Command, value []byte) { // Callback for Command_GETLOG Message type GetLogCallback struct { GenericCallback Logs Log Logs Log // Device log information } func (c *GetLogCallback) Success(resp *kproto.Command, value []byte) { Loading getlog.go +52 −46 Original line number Diff line number Diff line Loading @@ -83,47 +83,53 @@ func convertLogTypeFromProto(l kproto.Command_GetLog_Type) LogType { return ret } // UtilizationLog for kinetic drive utilization information type UtilizationLog struct { Name string Value float32 Name string // Name of the device utlity Value float32 // Value of device utility } type TemperatureLog struct { Name string Current float32 Minimum float32 Maximum float32 Target float32 Name string // Name of the drive Current float32 // Current Temperature Minimum float32 // Minimum Temperature for drive Maximum float32 // Maximum Tempture for drive Target float32 // Target Temperature for drive } type CapacityLog struct { CapacityInBytes uint64 PortionFull float32 CapacityInBytes uint64 // total capacity of hard disk, in bytes PortionFull float32 // remaining capacity of hard disk } type ConfigurationInterface struct { Name string MAC []byte Ipv4Addr []byte Ipv6Addr []byte Name string // network device name MAC []byte // network device mac address Ipv4Addr []byte // network device ipv4 address Ipv6Addr []byte // network device ipv6 address } type ConfigurationLog struct { Vendor string Model string SerialNumber []byte WorldWideName []byte Version string CompilationDate string SourceHash string ProtocolVersion string ProtocolCompilationDate string ProtocolSourceHash string Interface []ConfigurationInterface Port int32 TlsPort int32 Vendor string // Vendor name Model string // Device model SerialNumber []byte // Device serial number WorldWideName []byte // Device world wide name Version string // Device version CompilationDate string // Device service code compilation date SourceHash string // Device service source code repository hash value ProtocolVersion string // Device supported protocol version ProtocolCompilationDate string // Device supported protocol compilation date ProtocolSourceHash string // Device supported protocol source code repository hash value Interface []ConfigurationInterface // Device interfaces as list Port int32 // Service port TlsPort int32 // TLS service port } // Statistic information for each type of MessageType. // Count is total number of Type message processed. // Bytes is the sum of the data that is in the data portion. // This does not include the command description. // For P2P operations, this is the amount of data moved between drives type StatisticsLog struct { // TODO: Would it better just use the protocol Command_MessageType? Type MessageType Loading @@ -132,19 +138,19 @@ type StatisticsLog struct { } type LimitsLog struct { MaxKeySize uint32 MaxValueSize uint32 MaxVersionSize uint32 MaxTagSize uint32 MaxConnections uint32 MaxOutstandingReadRequests uint32 MaxOutstandingWriteRequests uint32 MaxMessageSize uint32 MaxKeyRangeCount uint32 MaxIdentityCount uint32 MaxPinSize uint32 MaxOperationCountPerBatch uint32 MaxBatchCountPerDevice uint32 MaxKeySize uint32 // max key size MaxValueSize uint32 // max value size MaxVersionSize uint32 // max version size MaxTagSize uint32 // max tag size MaxConnections uint32 // max connection MaxOutstandingReadRequests uint32 // max out standing read request MaxOutstandingWriteRequests uint32 // max out standing write request MaxMessageSize uint32 // max message size MaxKeyRangeCount uint32 // max key range count MaxIdentityCount uint32 // max identity count MaxPinSize uint32 // MaxOperationCountPerBatch uint32 // MaxBatchCountPerDevice uint32 // } type DeviceLog struct { Loading @@ -152,13 +158,13 @@ type DeviceLog struct { } type Log struct { Utilizations []UtilizationLog Temperatures []TemperatureLog Capacity CapacityLog Configuration ConfigurationLog Statistics []StatisticsLog Messages []byte Limits LimitsLog Utilizations []UtilizationLog // List of utilization information of the drive Temperatures []TemperatureLog // List of tempeture inforamtion of the drive Capacity CapacityLog // Capacity information of the drive Configuration ConfigurationLog // Configuration information of the drive Statistics []StatisticsLog // List of statistic information from the drive Messages []byte // Kinetic log messages from the drive Limits LimitsLog // Limits information from the drive Device DeviceLog } Loading handler.go +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import ( kproto "github.com/yongzhy/kinetic-go/proto" ) // ResponseHandler is the handler for XXXXX_RESPONSE message from drive. type ResponseHandler struct { callback Callback } Loading Loading @@ -36,6 +37,7 @@ func (h *ResponseHandler) SetCallback(call Callback) { h.callback = call } // Helper function to build a ResponseHandler with call as the Callback. func NewResponseHandler(call Callback) *ResponseHandler { h := &ResponseHandler{callback: call} return h Loading kinetic.go +16 −8 Original line number Diff line number Diff line /* Package kinetic is golang kinetic client implementation. For details about kinetic protocol, please refer to https://github.com/Kinetic/kinetic-protocol */ package kinetic import ( Loading @@ -14,6 +21,7 @@ func init() { klog.Out = os.Stdout } // ClientOptions type ClientOptions struct { Host string Port int Loading Loading @@ -484,14 +492,14 @@ type ACLPermission int32 const ( _ ACLPermission = iota ACL_PERMISSION_READ ACLPermission = iota ACL_PERMISSION_WRITE ACLPermission = iota ACL_PERMISSION_DELETE ACLPermission = iota ACL_PERMISSION_RANGE ACLPermission = iota ACL_PERMISSION_SETUP ACLPermission = iota ACL_PERMISSION_P2POP ACLPermission = iota ACL_PERMISSION_GETLOG ACLPermission = iota ACL_PERMISSION_SECURITY ACLPermission = iota ACL_PERMISSION_READ ACLPermission = iota // Can read key/values ACL_PERMISSION_WRITE ACLPermission = iota // Can write key/values ACL_PERMISSION_DELETE ACLPermission = iota // Can delete key/values ACL_PERMISSION_RANGE ACLPermission = iota // Can do a range ACL_PERMISSION_SETUP ACLPermission = iota // Can setup a device ACL_PERMISSION_P2POP ACLPermission = iota // Can do a peer to peer operation ACL_PERMISSION_GETLOG ACLPermission = iota // Can get log ACL_PERMISSION_SECURITY ACLPermission = iota // Can set up the security of device ) var strACLPermission = map[ACLPermission]string{ Loading Loading
blockconnection.go +1 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ type BlockConnection struct { nbc *NonBlockConnection } // Helper function to establish block connection to device. func NewBlockConnection(op ClientOptions) (*BlockConnection, error) { nbc, err := NewNonBlockConnection(op) if err != nil { Loading
callback.go +13 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,11 @@ import ( kproto "github.com/yongzhy/kinetic-go/proto" ) // Callback is the interface define actions for MessageType. // Success is called when XXXXX_RESPONSE message recieved from drive without problem. // Failure is called when XXXXX_RESPONSE message status code is not OK, or any other kind of failure. // Done return true if either Success or Failure is called to indicate XXXXX_RESPONSE received and processed. // Status return the MessateType operation status. type Callback interface { Success(resp *kproto.Command, value []byte) Failure(status Status) Loading @@ -11,7 +16,8 @@ type Callback interface { Status() Status } // Generic Callback, for Message which doesn't require data from Kinetic drive. // Generic Callback, can be used for all MessageType which doesn't require data from Kinetic drive. // And for MessageType that require data from drive, a new struct need to be defined GenericCallback type GenericCallback struct { done bool status Status Loading Loading @@ -40,9 +46,11 @@ func (c *GenericCallback) Status() Status { // Callback for Command_GET Message type GetCallback struct { GenericCallback Entry Record Entry Record // Entity information } // Success function extracts object information from kinetic message protocol and // store into GetCallback.Entry. func (c *GetCallback) Success(resp *kproto.Command, value []byte) { c.GenericCallback.Success(resp, value) c.Entry.Key = resp.GetBody().GetKeyValue().GetKey() Loading @@ -56,7 +64,7 @@ func (c *GetCallback) Success(resp *kproto.Command, value []byte) { // Callback for Command_GETKEYRANGE Message type GetKeyRangeCallback struct { GenericCallback Keys [][]byte Keys [][]byte // List of objects' keys within range, get from device } func (c *GetKeyRangeCallback) Success(resp *kproto.Command, value []byte) { Loading @@ -67,7 +75,7 @@ func (c *GetKeyRangeCallback) Success(resp *kproto.Command, value []byte) { // Callback for Command_GETVERSION Message type GetVersionCallback struct { GenericCallback Version []byte Version []byte // Version of the object on device } func (c *GetVersionCallback) Success(resp *kproto.Command, value []byte) { Loading @@ -93,7 +101,7 @@ func (c *P2PPushCallback) Success(resp *kproto.Command, value []byte) { // Callback for Command_GETLOG Message type GetLogCallback struct { GenericCallback Logs Log Logs Log // Device log information } func (c *GetLogCallback) Success(resp *kproto.Command, value []byte) { Loading
getlog.go +52 −46 Original line number Diff line number Diff line Loading @@ -83,47 +83,53 @@ func convertLogTypeFromProto(l kproto.Command_GetLog_Type) LogType { return ret } // UtilizationLog for kinetic drive utilization information type UtilizationLog struct { Name string Value float32 Name string // Name of the device utlity Value float32 // Value of device utility } type TemperatureLog struct { Name string Current float32 Minimum float32 Maximum float32 Target float32 Name string // Name of the drive Current float32 // Current Temperature Minimum float32 // Minimum Temperature for drive Maximum float32 // Maximum Tempture for drive Target float32 // Target Temperature for drive } type CapacityLog struct { CapacityInBytes uint64 PortionFull float32 CapacityInBytes uint64 // total capacity of hard disk, in bytes PortionFull float32 // remaining capacity of hard disk } type ConfigurationInterface struct { Name string MAC []byte Ipv4Addr []byte Ipv6Addr []byte Name string // network device name MAC []byte // network device mac address Ipv4Addr []byte // network device ipv4 address Ipv6Addr []byte // network device ipv6 address } type ConfigurationLog struct { Vendor string Model string SerialNumber []byte WorldWideName []byte Version string CompilationDate string SourceHash string ProtocolVersion string ProtocolCompilationDate string ProtocolSourceHash string Interface []ConfigurationInterface Port int32 TlsPort int32 Vendor string // Vendor name Model string // Device model SerialNumber []byte // Device serial number WorldWideName []byte // Device world wide name Version string // Device version CompilationDate string // Device service code compilation date SourceHash string // Device service source code repository hash value ProtocolVersion string // Device supported protocol version ProtocolCompilationDate string // Device supported protocol compilation date ProtocolSourceHash string // Device supported protocol source code repository hash value Interface []ConfigurationInterface // Device interfaces as list Port int32 // Service port TlsPort int32 // TLS service port } // Statistic information for each type of MessageType. // Count is total number of Type message processed. // Bytes is the sum of the data that is in the data portion. // This does not include the command description. // For P2P operations, this is the amount of data moved between drives type StatisticsLog struct { // TODO: Would it better just use the protocol Command_MessageType? Type MessageType Loading @@ -132,19 +138,19 @@ type StatisticsLog struct { } type LimitsLog struct { MaxKeySize uint32 MaxValueSize uint32 MaxVersionSize uint32 MaxTagSize uint32 MaxConnections uint32 MaxOutstandingReadRequests uint32 MaxOutstandingWriteRequests uint32 MaxMessageSize uint32 MaxKeyRangeCount uint32 MaxIdentityCount uint32 MaxPinSize uint32 MaxOperationCountPerBatch uint32 MaxBatchCountPerDevice uint32 MaxKeySize uint32 // max key size MaxValueSize uint32 // max value size MaxVersionSize uint32 // max version size MaxTagSize uint32 // max tag size MaxConnections uint32 // max connection MaxOutstandingReadRequests uint32 // max out standing read request MaxOutstandingWriteRequests uint32 // max out standing write request MaxMessageSize uint32 // max message size MaxKeyRangeCount uint32 // max key range count MaxIdentityCount uint32 // max identity count MaxPinSize uint32 // MaxOperationCountPerBatch uint32 // MaxBatchCountPerDevice uint32 // } type DeviceLog struct { Loading @@ -152,13 +158,13 @@ type DeviceLog struct { } type Log struct { Utilizations []UtilizationLog Temperatures []TemperatureLog Capacity CapacityLog Configuration ConfigurationLog Statistics []StatisticsLog Messages []byte Limits LimitsLog Utilizations []UtilizationLog // List of utilization information of the drive Temperatures []TemperatureLog // List of tempeture inforamtion of the drive Capacity CapacityLog // Capacity information of the drive Configuration ConfigurationLog // Configuration information of the drive Statistics []StatisticsLog // List of statistic information from the drive Messages []byte // Kinetic log messages from the drive Limits LimitsLog // Limits information from the drive Device DeviceLog } Loading
handler.go +2 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import ( kproto "github.com/yongzhy/kinetic-go/proto" ) // ResponseHandler is the handler for XXXXX_RESPONSE message from drive. type ResponseHandler struct { callback Callback } Loading Loading @@ -36,6 +37,7 @@ func (h *ResponseHandler) SetCallback(call Callback) { h.callback = call } // Helper function to build a ResponseHandler with call as the Callback. func NewResponseHandler(call Callback) *ResponseHandler { h := &ResponseHandler{callback: call} return h Loading
kinetic.go +16 −8 Original line number Diff line number Diff line /* Package kinetic is golang kinetic client implementation. For details about kinetic protocol, please refer to https://github.com/Kinetic/kinetic-protocol */ package kinetic import ( Loading @@ -14,6 +21,7 @@ func init() { klog.Out = os.Stdout } // ClientOptions type ClientOptions struct { Host string Port int Loading Loading @@ -484,14 +492,14 @@ type ACLPermission int32 const ( _ ACLPermission = iota ACL_PERMISSION_READ ACLPermission = iota ACL_PERMISSION_WRITE ACLPermission = iota ACL_PERMISSION_DELETE ACLPermission = iota ACL_PERMISSION_RANGE ACLPermission = iota ACL_PERMISSION_SETUP ACLPermission = iota ACL_PERMISSION_P2POP ACLPermission = iota ACL_PERMISSION_GETLOG ACLPermission = iota ACL_PERMISSION_SECURITY ACLPermission = iota ACL_PERMISSION_READ ACLPermission = iota // Can read key/values ACL_PERMISSION_WRITE ACLPermission = iota // Can write key/values ACL_PERMISSION_DELETE ACLPermission = iota // Can delete key/values ACL_PERMISSION_RANGE ACLPermission = iota // Can do a range ACL_PERMISSION_SETUP ACLPermission = iota // Can setup a device ACL_PERMISSION_P2POP ACLPermission = iota // Can do a peer to peer operation ACL_PERMISSION_GETLOG ACLPermission = iota // Can get log ACL_PERMISSION_SECURITY ACLPermission = iota // Can set up the security of device ) var strACLPermission = map[ACLPermission]string{ Loading