forked from golang/hotime
事务支持
This commit is contained in:
parent
3621dddf3d
commit
b4f0d5a29c
129
.idea/workspace.xml
generated
129
.idea/workspace.xml
generated
@ -5,9 +5,6 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" readonly="true" id="03ed5703-81a1-441b-849c-c426276586b7" name="Default" comment="">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/hotime.iml" afterPath="$PROJECT_DIR$/.idea/hotime.iml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/libraries/GOPATH__hotime_.xml" afterPath="$PROJECT_DIR$/.idea/libraries/GOPATH__hotime_.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/misc.xml" afterPath="$PROJECT_DIR$/.idea/misc.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/db.go" afterPath="$PROJECT_DIR$/db.go" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/example/main.go" afterPath="$PROJECT_DIR$/example/main.go" />
|
||||
@ -52,11 +49,11 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="config.json" pinned="false" current-in-tab="true">
|
||||
<file leaf-file-name="config.json" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/config/config.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="238">
|
||||
<caret line="14" column="15" selection-start-line="14" selection-start-column="15" selection-end-line="14" selection-end-column="15" />
|
||||
<state relative-caret-position="289">
|
||||
<caret line="17" column="1" selection-start-line="17" selection-start-column="1" selection-end-line="17" selection-end-column="1" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -72,11 +69,21 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="main.go" pinned="false" current-in-tab="false">
|
||||
<file leaf-file-name="main.go" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/example/main.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="206">
|
||||
<caret line="52" column="55" selection-start-line="52" selection-start-column="55" selection-end-line="52" selection-end-column="55" />
|
||||
<state relative-caret-position="325">
|
||||
<caret line="56" column="59" selection-start-line="56" selection-start-column="59" selection-end-line="56" selection-end-column="59" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="hashmap.go" pinned="false" current-in-tab="false">
|
||||
<entry file="file://D:/app/go/src/runtime/hashmap.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-123">
|
||||
<caret line="251" column="0" selection-start-line="251" selection-start-column="0" selection-end-line="251" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -105,18 +112,8 @@
|
||||
<file leaf-file-name="db.go" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/db.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="43">
|
||||
<caret line="32" column="22" selection-start-line="32" selection-start-column="22" selection-end-line="32" selection-end-column="22" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="cache_memory.go" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/cache_memory.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="9" column="15" selection-start-line="9" selection-start-column="15" selection-end-line="9" selection-end-column="15" />
|
||||
<state relative-caret-position="377">
|
||||
<caret line="324" column="0" selection-start-line="324" selection-start-column="0" selection-end-line="324" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -177,9 +174,9 @@
|
||||
<option value="$PROJECT_DIR$/cache_memory.go" />
|
||||
<option value="$PROJECT_DIR$/context.go" />
|
||||
<option value="$PROJECT_DIR$/session.go" />
|
||||
<option value="$PROJECT_DIR$/config/config.json" />
|
||||
<option value="$PROJECT_DIR$/db.go" />
|
||||
<option value="$PROJECT_DIR$/example/main.go" />
|
||||
<option value="$PROJECT_DIR$/config/config.json" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -243,6 +240,20 @@
|
||||
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="hotime" />
|
||||
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="hotime" />
|
||||
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
|
||||
</PATH_ELEMENT>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="example" />
|
||||
<option name="myItemType" value="com.jetbrains.php.projectView.PhpTreeStructureProvider$1" />
|
||||
</PATH_ELEMENT>
|
||||
</PATH>
|
||||
<PATH>
|
||||
<PATH_ELEMENT>
|
||||
<option name="myItemId" value="hotime" />
|
||||
@ -417,7 +428,7 @@
|
||||
<workItem from="1502935911308" duration="1724000" />
|
||||
<workItem from="1503366689326" duration="2378000" />
|
||||
<workItem from="1503451223794" duration="6314000" />
|
||||
<workItem from="1503507147874" duration="326000" />
|
||||
<workItem from="1503507147874" duration="997000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001">
|
||||
<created>1500458878821</created>
|
||||
@ -545,11 +556,18 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1503455663070</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="19" />
|
||||
<task id="LOCAL-00019" summary="demo">
|
||||
<created>1503507485133</created>
|
||||
<option name="number" value="00019" />
|
||||
<option name="presentableId" value="LOCAL-00019" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1503507485133</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="20" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="64897000" />
|
||||
<option name="totallyTimeSpent" value="65568000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
@ -562,14 +580,14 @@
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="54" y="-8" width="1874" height="1096" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<editor active="false" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.31146637" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.63343716" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32883817" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32917964" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24972437" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
@ -600,18 +618,11 @@
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<option name="time" value="3" />
|
||||
<option name="time" value="8" />
|
||||
</breakpoint-manager>
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/objtoobj.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1649">
|
||||
<caret line="97" column="5" selection-start-line="97" selection-start-column="5" selection-end-line="97" selection-end-column="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/error.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="255">
|
||||
@ -844,6 +855,9 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="357">
|
||||
<caret line="21" column="5" selection-start-line="21" selection-start-column="5" selection-end-line="21" selection-end-column="5" />
|
||||
<folding>
|
||||
<element signature="e#16#116#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -858,6 +872,9 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="204">
|
||||
<caret line="12" column="29" selection-start-line="12" selection-start-column="29" selection-end-line="12" selection-end-column="29" />
|
||||
<folding>
|
||||
<element signature="e#16#29#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -866,7 +883,7 @@
|
||||
<state relative-caret-position="34">
|
||||
<caret line="2" column="7" selection-start-line="2" selection-start-column="7" selection-end-line="2" selection-end-column="7" />
|
||||
<folding>
|
||||
<element signature="e#16#64#0" expanded="true" />
|
||||
<element signature="e#16#64#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@ -887,14 +904,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cache_db.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="10" column="15" selection-start-line="10" selection-start-column="15" selection-end-line="10" selection-end-column="15" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cache_memory.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
@ -945,26 +954,42 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/example/main.go">
|
||||
<entry file="file://$PROJECT_DIR$/config/config.json">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="206">
|
||||
<caret line="52" column="55" selection-start-line="52" selection-start-column="55" selection-end-line="52" selection-end-column="55" />
|
||||
<state relative-caret-position="289">
|
||||
<caret line="17" column="1" selection-start-line="17" selection-start-column="1" selection-end-line="17" selection-end-column="1" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cache_db.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="10" column="15" selection-start-line="10" selection-start-column="15" selection-end-line="10" selection-end-column="15" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://D:/app/go/src/runtime/hashmap.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-123">
|
||||
<caret line="251" column="0" selection-start-line="251" selection-start-column="0" selection-end-line="251" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/db.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="43">
|
||||
<caret line="32" column="22" selection-start-line="32" selection-start-column="22" selection-end-line="32" selection-end-column="22" />
|
||||
<state relative-caret-position="377">
|
||||
<caret line="324" column="0" selection-start-line="324" selection-start-column="0" selection-end-line="324" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/config/config.json">
|
||||
<entry file="file://$PROJECT_DIR$/example/main.go">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="238">
|
||||
<caret line="14" column="15" selection-start-line="14" selection-start-column="15" selection-end-line="14" selection-end-column="15" />
|
||||
<state relative-caret-position="325">
|
||||
<caret line="56" column="59" selection-start-line="56" selection-start-column="59" selection-end-line="56" selection-end-column="59" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
|
6
db.go
6
db.go
@ -31,13 +31,15 @@ func (this *HoTimeDB) SetConnect(connect func(err ...*Error) *sql.DB, err ...*Er
|
||||
|
||||
//事务,如果action返回true则执行成功;false则回滚
|
||||
func (this *HoTimeDB) Action(action func(db HoTimeDB) bool) bool {
|
||||
tx, err := this.DB.Begin()
|
||||
db:=HoTimeDB{DB:this.DB,Cached:this.Cached}
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
this.LastErr.SetError(err)
|
||||
return false
|
||||
}
|
||||
|
||||
db:=HoTimeDB{DB:this.DB,Tx:tx,Cached:this.Cached}
|
||||
db.Tx=tx
|
||||
|
||||
|
||||
result := action(db)
|
||||
|
||||
|
@ -54,7 +54,7 @@ func main() {
|
||||
|
||||
db.Insert("user",hotime.Map{"unickname":"dasdas"})
|
||||
|
||||
return false
|
||||
return true
|
||||
})
|
||||
this.Display(5, x)
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user